|
Why the extra blanks in the stat() data structure for the stat() IFS API's? This does not match the defined prototypes in the Information Center, C, or QSYSINC/SYS(STAT). See QSYSINC/SYS(TYPES) for definitions of some variables. In order to get the correct values using stat() and lstat(), blanks must be inserted in certain places. On the other hand, stat64() and lstat64() data structures match exactly with the Information Center, C, and QSYSINC/SYS(STAT). LARGE_FILE_API is automatically defined when using these stat64() API's. For those not familiar with any of these API's: Use lstat() instead of stat() to get attribute information distinguishing symbolic links from other objects. Use lstat64() or stat64() in order to get information on files over 2GB. Below, shows stat and stat64 data structures (same for lstat). Why is st_reserved1 and st_reserved2 required for RPG but never defined for the Information Center, C, or QSYSINC/SYS(STAT)? The stat64() data structure doesn't need those spaces. So, why does stat() need them? So, the definition for these API's (the stat() prototype is an example but would be the same for lstat(), stat64(), and lstat64()): * Retrieve information about an IFS file D stat PR 10I 0 ExtProc('stat') D path * Value Options(*String) D buf * Value * stat data sructure D p_statDS S * D statDS DS Based(p_statDS) D st_mode 10U 0 D st_ino 10U 0 D st_nlink 5U 0 D st_reserved1 2A D st_uid 10U 0 D st_gid 10U 0 D st_size 10I 0 D st_atime 10I 0 D st_mtime 10I 0 D st_ctime 10I 0 D st_dev 10U 0 D st_blksize 10U 0 D st_allocsize 10U 0 D st_objtype 11A D st_reserved2 1A D st_codepage 5U 0 D st_ccsid 5U 0 D st_reserved3 60A D st_ino_gen_id 10I 0 * stat data sructure for large files D p_statDS S * D statDS DS Based(p_statDS) D st_mode 10U 0 D st_ino 10U 0 D st_uid 10U 0 D st_gid 10U 0 D st_size 20I 0 D st_atime 10I 0 D st_mtime 10I 0 D st_ctime 10I 0 D st_dev 10U 0 D st_blksize 10U 0 D st_nlink 5U 0 D st_codepage 5U 0 D st_allocsize 20U 0 D st_ino_gen_id 10I 0 D st_objtype 11A D st_reserved1 55A D st_ccsid 5U 0 D FilPath S 5000A D statSize S 10I 0 D S_IFDIR S 10U 0 Inz(20000) C Eval statSize = %Size(statDS) C Alloc statSize p_statDS C Eval FilPath = '/dir/file.txt' * If file C If stat(%Trim(FilPath):p_statDS) = 0 and C st_mode > S_IFDIR C whatever code you want C EndIf C Dealloc p_statDS Thanks, Craig Strong craigs@dekko.com
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.