20 #ifndef MPD_FS_FILESYSTEM_HXX
21 #define MPD_FS_FILESYSTEM_HXX
47 return _tfopen(file.
c_str(), mode);
49 return fopen(file.
c_str(), mode);
60 return _topen(file.
c_str(), flags, mode);
82 int ret = follow_symlinks
83 ? stat(file.
c_str(), &buf)
84 : lstat(file.
c_str(), &buf);
115 return mkfifo(path.
c_str(), mode) == 0;
124 return access(path.
c_str(), mode) == 0;
136 (void)follow_symlinks;
138 const auto a = GetFileAttributes(path.
c_str());
139 return a != INVALID_FILE_ATTRIBUTES &&
140 (a & (FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_DEVICE)) == 0;
143 return StatFile(path, buf, follow_symlinks) && S_ISREG(buf.st_mode);
154 (void)follow_symlinks;
156 const auto a = GetFileAttributes(path.
c_str());
157 return a != INVALID_FILE_ATTRIBUTES && (a & FILE_ATTRIBUTE_DIRECTORY);
160 return StatFile(path, buf, follow_symlinks) && S_ISDIR(buf.st_mode);
171 return GetFileAttributes(path.
c_str()) != INVALID_FILE_ATTRIBUTES;
int open_cloexec(const char *path_fs, int flags, int mode)
Wrapper for open(), which sets the CLOEXEC flag (atomically if supported by the OS).
static bool PathExists(Path path)
Checks if Path exists.
void TruncateFile(Path path)
Truncate a file that exists already.
static FILE * FOpen(Path file, PathTraitsFS::const_pointer_type mode)
Wrapper for fopen() that uses Path names.
static bool StatFile(Path file, struct stat &buf, bool follow_symlinks=true)
Wrapper for stat() that uses Path names.
A path name in the native file system character set.
gcc_pure const_pointer_type c_str() const noexcept
Returns the value as a const C string.
static bool MakeFifo(Path path, mode_t mode)
void RemoveFile(Path path)
Wrapper for unlink() that uses Path names.
Pointer::const_pointer_type const_pointer_type
A path name in the native file system character set.
void RenameFile(Path oldpath, Path newpath)
AllocatedPath ReadLink(Path path)
Wrapper for readlink() that uses Path names.
static bool DirectoryExists(Path path, bool follow_symlinks=true)
Checks if Path exists and is a directory.
static bool CheckAccess(Path path, int mode)
Wrapper for access() that uses Path names.
static int OpenFile(Path file, int flags, int mode)
Wrapper for open_cloexec() that uses Path names.
static bool FileExists(Path path, bool follow_symlinks=true)
Checks if Path exists and is a regular file.