FileStat :: struct {
size: i64;
type: FileType;
+ change_time: u64; // in milliseconds
+ accessed_time: u64; // in milliseconds
+ modified_time: u64; // in milliseconds
}
file_exists :: fs.__file_exists
if err == .Success {
exists = true;
out.size = ~~ fs.size;
+ out.change_time = fs.ctim / 1000000;
+ out.accessed_time = fs.atim / 1000000;
+ out.modified_time = fs.mtim / 1000000;
switch fs.filetype {
case .RegularFile do out.type = .RegularFile;
#if !#defined(runtime.vars.WASIX) {
__chdir :: (path: str) => false
__getcwd :: () => ""
-}
\ No newline at end of file
+}
typedef struct bh_file_stats {
isize size;
u32 file_type;
+ u64 change_time;
+ u64 accessed_time;
+ u64 modified_time;
} bh_file_stats;
bh_file_error bh_file_get_standard(bh_file* file, bh_file_standard stand);
return 1;
}
+static u64 timespec_to_ms(struct timespec t) {
+ return t.tv_sec * 1000 + t.tv_nsec / 1000000;
+}
+
b32 bh_file_stat(char const* filename, bh_file_stats* out) {
struct stat s;
if (stat(filename, &s) == -1) {
}
out->size = s.st_size;
+ out->modified_time = timespec_to_ms(s.st_mtim);
+ out->accessed_time = timespec_to_ms(s.st_atim);
+ out->change_time = timespec_to_ms(s.st_ctim);
if ((s.st_mode & S_IFMT) == S_IFDIR) out->file_type = BH_FILE_TYPE_DIRECTORY;
if ((s.st_mode & S_IFMT) == S_IFREG) out->file_type = BH_FILE_TYPE_FILE;