|
On Wed, 7 Feb 2001, Goodbar, Loyd (AFS-Water Valley) wrote: > Is there a way I can get the attributes (date/time created/modified, file > size) for an IFS object in a CL or RPG/IV program? I have a batch file > running on an NT server that extracts some data from another server (Novell) > to a directory on the AS/400. On the AS/400 side, I want to ensure I have a > file created "today" before I try to process it. Yes, you can use the stat() API from the UNIX-Type APIs manual to get this information. Here's an example written in RPG IV. You might be able to do it in CL, but it'd be a lot more difficult. :) The time returned is in GMT, I believe. You may have to adjust it for your timezone. D********************************************************************** D* File Information Structure (stat) D* D* struct stat { D* mode_t st_mode; /* File mode */ D* ino_t st_ino; /* File serial number */ D* nlink_t st_nlink; /* Number of links */ D* uid_t st_uid; /* User ID of the owner of file */ D* gid_t st_gid; /* Group ID of the group of file */ D* off_t st_size; /* For regular files, the file D* * size in bytes */ D* time_t st_atime; /* Time of last access */ D* time_t st_mtime; /* Time of last data modification */ D* time_t st_ctime; /* Time of last file status change */ D* dev_t st_dev; /* ID of device containing file */ D* size_t st_blksize; /* Size of a block of the file */ D* unsigned long st_allocsize; /* Allocation size of the file */ D* qp0l_objtype_t st_objtype; /* AS/400 object type */ D* unsigned short st_codepage; /* Object data codepage */ D* char st_reserved1[66]; /* Reserved */ D* }; D* D statds DS D st_mode 10U 0 D st_ino 10U 0 D st_nlink 5U 0 D st_pad 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_alctize 10U 0 D st_objtype 12A D st_codepag 5U 0 D st_resv11 67A D*-------------------------------------------------------------------- D* Get File Information D* D* int stat(const char *path, struct stat *buf) D*-------------------------------------------------------------------- D stat PR 10I 0 ExtProc('stat') D path * value D buf * value D Path S 640A D Msg S 52A D ModTime S Z INZ(z'1970-01-01-00.00.00.00000') c eval Path = '/QOpenSys/usr/myfile.txt'+x'00' c if stat(%addr(Path): %addr(statds)) <> 0 c eval Msg = 'stat() failed!' c dsply Msg c eval *inlr = *on c return c endif c adddur st_mtime:*s ModTime c 'Changed' dsply ModTime c eval *inlr = *on +--- | This is the Midrange System Mailing List! | To submit a new message, send your mail to MIDRANGE-L@midrange.com. | To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com. | To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.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.