Merge pull request #4695 from leroycep/feature-inode-stat
Expose file inode number on posix and file index on windows
This commit is contained in:
commit
6ab156ce7d
@ -145,6 +145,16 @@ pub const File = struct {
|
||||
}
|
||||
|
||||
pub const Stat = struct {
|
||||
/// A number that the system uses to point to the file metadata. This number is not guaranteed to be
|
||||
/// unique across time, as some file systems may reuse an inode after it's file has been deleted.
|
||||
/// Some systems may change the inode of a file over time.
|
||||
///
|
||||
/// On Linux, the inode _is_ structure that stores the metadata, and the inode _number_ is what
|
||||
/// you see here: the index number of the inode.
|
||||
///
|
||||
/// The FileIndex on Windows is similar. It is a number for a file that is unique to each filesystem.
|
||||
inode: os.ino_t,
|
||||
|
||||
size: u64,
|
||||
mode: Mode,
|
||||
|
||||
@ -174,6 +184,7 @@ pub const File = struct {
|
||||
else => return windows.unexpectedStatus(rc),
|
||||
}
|
||||
return Stat{
|
||||
.inode = info.InternalInformation.IndexNumber,
|
||||
.size = @bitCast(u64, info.StandardInformation.EndOfFile),
|
||||
.mode = 0,
|
||||
.atime = windows.fromSysTime(info.BasicInformation.LastAccessTime),
|
||||
@ -187,6 +198,7 @@ pub const File = struct {
|
||||
const mtime = st.mtime();
|
||||
const ctime = st.ctime();
|
||||
return Stat{
|
||||
.inode = st.ino,
|
||||
.size = @bitCast(u64, st.size),
|
||||
.mode = st.mode,
|
||||
.atime = @as(i64, atime.tv_sec) * std.time.ns_per_s + atime.tv_nsec,
|
||||
|
@ -53,6 +53,7 @@ pub const mach_timebase_info_data = extern struct {
|
||||
};
|
||||
|
||||
pub const off_t = i64;
|
||||
pub const ino_t = u64;
|
||||
|
||||
/// Renamed to Stat to not conflict with the stat function.
|
||||
/// atime, mtime, and ctime have functions to return `timespec`,
|
||||
@ -64,7 +65,7 @@ pub const Stat = extern struct {
|
||||
dev: i32,
|
||||
mode: u16,
|
||||
nlink: u16,
|
||||
ino: u64,
|
||||
ino: ino_t,
|
||||
uid: u32,
|
||||
gid: u32,
|
||||
rdev: i32,
|
||||
|
@ -138,8 +138,10 @@ pub const MAP_SIZEALIGN = 262144;
|
||||
|
||||
pub const PATH_MAX = 1024;
|
||||
|
||||
pub const ino_t = c_ulong;
|
||||
|
||||
pub const Stat = extern struct {
|
||||
ino: c_ulong,
|
||||
ino: ino_t,
|
||||
nlink: c_uint,
|
||||
dev: c_uint,
|
||||
mode: c_ushort,
|
||||
|
@ -98,6 +98,7 @@ pub const msghdr_const = extern struct {
|
||||
};
|
||||
|
||||
pub const off_t = i64;
|
||||
pub const ino_t = u64;
|
||||
|
||||
/// Renamed to Stat to not conflict with the stat function.
|
||||
/// atime, mtime, and ctime have functions to return `timespec`,
|
||||
@ -107,7 +108,7 @@ pub const off_t = i64;
|
||||
/// methods to accomplish this.
|
||||
pub const Stat = extern struct {
|
||||
dev: u64,
|
||||
ino: u64,
|
||||
ino: ino_t,
|
||||
nlink: usize,
|
||||
|
||||
mode: u16,
|
||||
|
@ -481,6 +481,7 @@ pub const msghdr_const = extern struct {
|
||||
};
|
||||
|
||||
pub const off_t = i64;
|
||||
pub const ino_t = u64;
|
||||
|
||||
/// Renamed to Stat to not conflict with the stat function.
|
||||
/// atime, mtime, and ctime have functions to return `timespec`,
|
||||
@ -490,7 +491,7 @@ pub const off_t = i64;
|
||||
/// methods to accomplish this.
|
||||
pub const Stat = extern struct {
|
||||
dev: u64,
|
||||
ino: u64,
|
||||
ino: ino_t,
|
||||
nlink: usize,
|
||||
|
||||
mode: u32,
|
||||
|
@ -69,6 +69,7 @@ pub const msghdr_const = extern struct {
|
||||
};
|
||||
|
||||
pub const off_t = i64;
|
||||
pub const ino_t = u64;
|
||||
|
||||
/// Renamed to Stat to not conflict with the stat function.
|
||||
/// atime, mtime, and ctime have functions to return `timespec`,
|
||||
@ -79,7 +80,7 @@ pub const off_t = i64;
|
||||
pub const Stat = extern struct {
|
||||
dev: u64,
|
||||
mode: u32,
|
||||
ino: u64,
|
||||
ino: ino_t,
|
||||
nlink: usize,
|
||||
|
||||
uid: u32,
|
||||
|
@ -178,6 +178,7 @@ pub const FILESTAT_SET_MTIM: fstflags_t = 0x0004;
|
||||
pub const FILESTAT_SET_MTIM_NOW: fstflags_t = 0x0008;
|
||||
|
||||
pub const inode_t = u64;
|
||||
pub const ino_t = inode_t;
|
||||
|
||||
pub const linkcount_t = u32;
|
||||
|
||||
|
@ -4,6 +4,7 @@ usingnamespace @import("../windows/bits.zig");
|
||||
const ws2_32 = @import("../windows/ws2_32.zig");
|
||||
|
||||
pub const fd_t = HANDLE;
|
||||
pub const ino_t = LARGE_INTEGER;
|
||||
pub const pid_t = HANDLE;
|
||||
pub const mode_t = u0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user