/******************************************************************************* * c0xfstat.h * Test implementation for the ISO C proposal at: * . * * This code is designed to run reasonably well on Unix and Win32 systems. * * Contains * _FILE_PERM_XXX * _FILE_TYPE_XXX * _TIME_UNKNOWN * struct _fileinfo * _fgetfileinfo() * _getfileinfo() * * Notes * Compile with macro '_unix' defined for Unix systems. * * Acknowledgments * This code was written by David R. Tribble, Oct 2003. * It is hereby placed into the public domain, and may be used for all * purposes, both commercial and private. No warranty is provided for this * source code, and the author cannot be held liable for its use in any * way. * * See also * * * */ #ifndef drt_c0xfstat_h #define drt_c0xfstat_h 105 /* Identification */ #ifndef NO_H_IDENT static const char drt_c0xfstat_h_REV[] = "@(#)drt/text/stdc/c0xfstat.h $Revision: 1.5 $ $Date: 2003/12/30 20:27:07 $\n"; #endif /* System includes */ #include #include /*------------------------------------------------------------------------------ * Types */ #if defined(_WIN32) typedef __int64 llong_t; typedef unsigned __int64 ullong_t; #elif defined(_unix) typedef long long int llong_t; typedef unsigned long long int ullong_t; #else #error Unsupported O/S #endif /*------------------------------------------------------------------------------ * Constants */ /* File types */ #define _FILE_TYPE_UNKNOWN 0 #define _FILE_TYPE_FILE 1 #define _FILE_TYPE_DIR 2 #ifdef S_IFBLK #define _FILE_TYPE_BLOCK 3 #endif #ifdef S_IFCHR #define _FILE_TYPE_CHAR 4 #endif #ifdef S_IFIFO #define _FILE_TYPE_FIFO 5 #endif #ifdef S_IFLNK #define _FILE_TYPE_SYMLINK 6 #endif #ifdef S_IFSOCK #define _FILE_TYPE_SOCKET 7 #endif /* File permissions */ #define _FILE_PERM_READ 0x0004 #define _FILE_PERM_WRITE 0x0002 #define _FILE_PERM_EXEC 0x0001 #define _FILE_PERM_SEARCH 0x0008 #if defined(_unix) #define _FILE_PERM_READ_USR 0x0040 #define _FILE_PERM_READ_GRP 0x0400 #define _FILE_PERM_READ_OTH 0x4000 #define _FILE_PERM_WRITE_USR 0x0020 #define _FILE_PERM_WRITE_GRP 0x0200 #define _FILE_PERM_WRITE_OTH 0x2000 #define _FILE_PERM_EXEC_USR 0x0010 #define _FILE_PERM_EXEC_GRP 0x0100 #define _FILE_PERM_EXEC_OTH 0x1000 #define _FILE_PERM_SEARCH_USR 0x0010 #define _FILE_PERM_SEARCH_GRP 0x0100 #define _FILE_PERM_SEARCH_OTH 0x1000 #endif /* Special time value */ #define _TIME_UNKNOWN ((time_t) -1) /*------------------------------------------------------------------------------ * struct _fileinfo * File information. * * Members marked with '(*)' are extensions to the proposed standard. * * @see * * * @since 1.1, 2003-10-07 */ #define _FILEINFO_VERS 2 /* Struct version */ struct _fileinfo { int fi_vers; /* Struct version (*) */ int fi_type; /* File type */ unsigned long int fi_perms; /* Access permissions */ llong_t fi_size; /* Size, in bytes */ time_t fi_created; /* Creation time */ time_t fi_modified; /* Modification time */ time_t fi_accessed; /* Last access time */ time_t fi_changed; /* Last status change time (*) */ long int fi_id; /* Serial number */ char fi_filesys[16+1]; /* File system identity */ unsigned char fi__r[19]; /* Reserved (*) */ }; /*------------------------------------------------------------------------------ * _getfileinfo() * Retrieve information about a file name. * * @param fname * File or directory name. * * @param info * Pointer to a file information structure. * * @return * Zero if successful and the structure pointed to by 'info' is filled with * information about the file; otherwise -1. * * @since 1.1, 2003-10-07 */ extern int _getfileinfo(const char *fname, struct _fileinfo *info); /*------------------------------------------------------------------------------ * _fgetfileinfo() * Retrieve information about an I/O stream. * * @param fp * An I/O stream. * This should not be null, nor should it point to a closed stream. * * @param info * Pointer to a file information structure. * * @return * Zero if successful and the structure pointed to by 'info' is filled with * information about the stream; otherwise -1. * * @since 1.1, 2003-10-07 */ extern int _fgetfileinfo(FILE *fp, struct _fileinfo *info); #endif /* drt_c0xfstat_h */ /* End c0xfstat.h */