return fileStatus(path) == 1;
}
-int createFile(const std::string &path)
-{
- int fd = open(path.c_str(), O_RDONLY|O_CREAT, 0644);
- if (fd == -1) {
- LogError("Failed to create file: " << path << " " << GetErrnoString(errno));
- return SECURITY_MANAGER_ERROR_FILE_CREATE_FAILED;
- }
- close(fd);
- return SECURITY_MANAGER_SUCCESS;
-}
-
int removeFile(const std::string &path)
{
int ret = unlink(path.c_str());
return src && dst ? SECURITY_MANAGER_SUCCESS : SECURITY_MANAGER_ERROR_FILE_CREATE_FAILED;
}
-int truncateFile(const std::string &path) {
- std::ofstream dst(path, std::ios::binary|std::ios::trunc);
- dst.close();
- return dst ? SECURITY_MANAGER_SUCCESS : SECURITY_MANAGER_ERROR_FILE_CREATE_FAILED;
-}
-
off_t fileSize(const std::string &path) {
struct stat st;
static_assert(std::is_same<off_t, decltype(st.st_size)>::value);
int removeDirectory(const std::string &path);
int fileStatus(const std::string &path);
bool fileExists(const std::string &path);
-int createFile(const std::string &path);
int removeFile(const std::string &path);
int symLink(const std::string &src, const std::string &dst);
int overwriteFile(const std::string &src, const std::string &dst);
-int truncateFile(const std::string &path);
off_t fileSize(const std::string &path); // < 0 on error
} // namespace FS