stat

A wrapper for the POSIX stat() function. The stat() function returns information about a file. On Windows the stat() function in the C library checks only the FAT-style READONLY attribute and does not look at the ACL at all. Thus on Windows the protection bits in the st_mode field are a fabrication of little use.

On Windows the Microsoft C libraries have several variants of the stat struct and stat() function with names like stat(), _stat32(), _stat32i64() and _stat64i32(). The one used here is for 32-bit code the one with 32-bit size and time fields, specifically called _stat32().

In Microsoft's compiler, by default struct stat means one with 64-bit time fields while in MinGW struct stat is the legacy one with 32-bit fields. To hopefully clear up this messs, the gstdio.h header defines a type #GStatBuf which is the appropriate struct type depending on the platform and/or compiler being used. On POSIX it is just struct stat, but note that even on POSIX platforms, stat() might be a macro.

See your C library manual for more details about stat().

Parameters

filename string

a pathname in the GLib file name encoding (UTF-8 on Windows)

buf glib.types.StatBuf

a pointer to a stat struct, which will be filled with the file information

Return Value

Type: int

0 if the information was successfully retrieved, -1 if an error occurred