Skip to content

Commit

Permalink
Expose st_dev and st_ino fields of stat structure (#1589)
Browse files Browse the repository at this point in the history
Expose `st_dev` and `st_ino` fields of stat structure to pony's
FileInfo type.

* FileInfo: typo for `device` field changed from U32 to U64
  • Loading branch information
zevlg authored and Benoit Vey committed Feb 16, 2017
1 parent 3d4c578 commit 89007c7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/files/file_info.pony
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ class val FileInfo
This contains file system metadata for a path. The times are in the same
format as Time.now(), i.e. seconds and nanoseconds since the epoch.
The INODE is UNIX specific. It will be zero on Windows.
The UID and GID are UNIX-style user and group IDs. These will be zero on
Windows. The change_time will actually be the file creation time on Windows.
Expand All @@ -14,6 +16,8 @@ class val FileInfo

let mode: FileMode val = recover FileMode end
let hard_links: U32 = 0
let device: U64 = 0
let inode: U64 = 0
let uid: U32 = 0
let gid: U32 = 0
let size: USize = 0
Expand Down
6 changes: 6 additions & 0 deletions src/libponyrt/lang/stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ typedef struct pony_stat_t
pony_mode_t* mode;

uint32_t hard_links;
uint64_t device;
uint64_t inode;
uint32_t uid;
uint32_t gid;
size_t size;
Expand Down Expand Up @@ -69,6 +71,8 @@ static void windows_stat(const char* path, pony_stat_t* p, struct __stat64* st,
p->broken = false;

p->hard_links = (uint32_t)st->st_nlink;
p->device = (uint64_t)st->st_dev;
p->inode = (uint64_t)st->st_ino;
p->uid = st->st_uid;
p->gid = st->st_gid;
p->size = st->st_size;
Expand Down Expand Up @@ -113,6 +117,8 @@ static void unix_stat(pony_stat_t* p, struct stat* st)
{
// Report information other than size based on the symlink if there is one.
p->hard_links = (uint32_t)st->st_nlink;
p->device = (uint64_t)st->st_dev;
p->inode = (uint64_t)st->st_ino;
p->uid = st->st_uid;
p->gid = st->st_gid;

Expand Down

0 comments on commit 89007c7

Please sign in to comment.