Base: Implement FileInfo::size()

This commit is contained in:
wmayer
2024-03-10 08:46:49 +01:00
committed by wwmayer
parent aa58cef2f9
commit dfc252666e

View File

@@ -451,9 +451,26 @@ bool FileInfo::isDir() const
unsigned int FileInfo::size() const
{
// not implemented
assert(0);
return 0;
unsigned int bytes {};
if (exists()) {
#if defined(FC_OS_WIN32)
std::wstring wstr = toStdWString();
struct _stat st;
if (_wstat(wstr.c_str(), &st) == 0) {
bytes = st.st_size;
}
#elif defined(FC_OS_LINUX) || defined(FC_OS_CYGWIN) || defined(FC_OS_MACOSX) || defined(FC_OS_BSD)
struct stat st
{
};
if (stat(FileName.c_str(), &st) == 0) {
bytes = st.st_size;
}
#endif
}
return bytes;
}
TimeInfo FileInfo::lastModified() const