|
|
@@ -8,6 +8,7 @@
|
|
|
|
|
|
#include "bx.h"
|
|
|
#include "debug.h"
|
|
|
+#include <sys/stat.h>
|
|
|
|
|
|
#if BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT
|
|
|
# include <windows.h>
|
|
|
@@ -274,6 +275,46 @@ namespace bx
|
|
|
#endif // BX_COMPILER_
|
|
|
}
|
|
|
|
|
|
+ struct FileInfo
|
|
|
+ {
|
|
|
+ enum Enum
|
|
|
+ {
|
|
|
+ Regular,
|
|
|
+ Directory,
|
|
|
+
|
|
|
+ Count
|
|
|
+ };
|
|
|
+
|
|
|
+ uint64_t m_size;
|
|
|
+ Enum m_type;
|
|
|
+ };
|
|
|
+
|
|
|
+ inline bool stat(const char* _filePath, FileInfo& _fileInfo)
|
|
|
+ {
|
|
|
+ _fileInfo.m_size = 0;
|
|
|
+ _fileInfo.m_type = FileInfo::Count;
|
|
|
+
|
|
|
+ struct stat st;
|
|
|
+ int32_t result = ::stat(_filePath, &st);
|
|
|
+ if (0 != result)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (0 != (st.st_mode & S_IFREG) )
|
|
|
+ {
|
|
|
+ _fileInfo.m_type = FileInfo::Regular;
|
|
|
+ }
|
|
|
+ else if (0 != (st.st_mode & S_IFDIR) )
|
|
|
+ {
|
|
|
+ _fileInfo.m_type = FileInfo::Directory;
|
|
|
+ }
|
|
|
+
|
|
|
+ _fileInfo.m_size = st.st_size;
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
} // namespace bx
|
|
|
|
|
|
#endif // BX_OS_H_HEADER_GUARD
|