feat: refactor files module: platform abstractions, filesystem error
handling
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
//! ```
|
||||
|
||||
const std = @import("std");
|
||||
const platform_time = @import("platform").time;
|
||||
const Allocator = std.mem.Allocator;
|
||||
|
||||
/// Error types for MockFS operations
|
||||
@@ -47,8 +48,8 @@ pub const MockFile = struct {
|
||||
return .{
|
||||
.allocator = allocator,
|
||||
.data = &[_]u8{},
|
||||
.created_at = std.time.timestamp(),
|
||||
.modified_at = std.time.timestamp(),
|
||||
.created_at = platform_time.timestamp(),
|
||||
.modified_at = platform_time.timestamp(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -71,7 +72,7 @@ pub const MockFile = struct {
|
||||
self.allocator.free(self.data);
|
||||
}
|
||||
self.data = new_data;
|
||||
self.modified_at = std.time.timestamp();
|
||||
self.modified_at = platform_time.timestamp();
|
||||
}
|
||||
|
||||
pub fn resize(self: *MockFile, new_size: usize) !void {
|
||||
@@ -91,7 +92,7 @@ pub const MockFile = struct {
|
||||
self.allocator.free(self.data);
|
||||
}
|
||||
self.data = new_data;
|
||||
self.modified_at = std.time.timestamp();
|
||||
self.modified_at = platform_time.timestamp();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -149,7 +150,7 @@ pub const MockFileHandle = struct {
|
||||
// Copy data
|
||||
@memcpy(file.data[self.position..][0..data.len], data);
|
||||
self.position += data.len;
|
||||
file.modified_at = std.time.timestamp();
|
||||
file.modified_at = platform_time.timestamp();
|
||||
return data.len;
|
||||
}
|
||||
|
||||
@@ -168,7 +169,7 @@ pub const MockFileHandle = struct {
|
||||
|
||||
// Copy data
|
||||
@memcpy(file.data[off..][0..data.len], data);
|
||||
file.modified_at = std.time.timestamp();
|
||||
file.modified_at = platform_time.timestamp();
|
||||
return data.len;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user