20 #ifndef MPD_FS_FILE_INFO_HXX
21 #define MPD_FS_FILE_INFO_HXX
37 static inline constexpr uint64_t
38 ConstructUint64(DWORD lo, DWORD hi)
40 return uint64_t(lo) | (uint64_t(hi) << 32);
43 static constexpr time_t
44 FileTimeToTimeT(FILETIME ft)
46 return (ConstructUint64(ft.dwLowDateTime, ft.dwHighDateTime)
47 - 116444736000000000) / 10000000;
54 bool follow_symlinks);
58 WIN32_FILE_ATTRIBUTE_DATA data;
69 throw FormatLastError(
"Failed to access %s",
80 return (data.dwFileAttributes &
81 (FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_DEVICE)) == 0;
83 return S_ISREG(st.st_mode);
89 return data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
91 return S_ISDIR(st.st_mode);
97 return ConstructUint64(data.nFileSizeLow, data.nFileSizeHigh);
105 return FileTimeToTimeT(data.ftLastWriteTime);
134 (void)follow_symlinks;
135 return GetFileAttributesEx(path.
c_str(), GetFileExInfoStandard,
138 int ret = follow_symlinks
139 ? stat(path.
c_str(), &info.st)
140 : lstat(path.
c_str(), &info.st);
time_t GetModificationTime() const
friend bool GetFileInfo(Path path, FileInfo &info, bool follow_symlinks)
A path name in the native file system character set.
bool GetFileInfo(Path path, FileInfo &info, bool follow_symlinks=true)
gcc_pure std::string ToUTF8() const
Convert the path to UTF-8.
FileInfo(Path path, bool follow_symlinks=true)
gcc_pure const_pointer_type c_str() const
Returns the value as a const C string.
static std::system_error FormatErrno(int code, const char *fmt, Args &&...args)