Hier ist das Teil in RPG.
PHP-Code:
h DFTACTGRP(*NOBNDDIR('QC2LE')           
 * 
'stat' Datenstruktur                  
d stat_ds         DS                  Align
d st_mode                       10U 0      
d st_ino                        10U 0      
d st_nlink                       5U 0      
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_alcsize                    10U 0      
d st_objtype                    11A        
d st_codepag                     5U 0      
d st_resv11                     66A        
 
'tm' Datenstruktur                    
d tm_ds           DS                  Align
d tm_sec                        10I 0      
d tm_min                        10I 0      
d tm_hour                       10I 0      
d tm_mday                       10I 0                                                                
d tm_mon                        10I 0                                                                
d tm_year                       10I 0                                                                
d tm_wday                       10I 0                                                                
d tm_yday                       10I 0                                                                
d tm_isdst                      10I 0                                                                
 
'stat' UNIX-Type API                                                                            
d stat            PR            10I 0 ExtProc
('stat')                                                
d                                 *   Value                                                          
d                                 
*   Value                                                          
 
'localtime_r' ILE-for AS/400 Run-Time-Library                                                 
d localtime_r     PR            10I 0 ExtProc
('localtime_r')                                         
d                                 *   Value                                                          
d                                 
*   Value                                                          
 
Weitere Felddeklarationen                                                                         
d stmf            S            256A                                        Datenstromdatei           
d adate           S              8S 0                                      Datum des letzten Zugriffs
d mdate           S              8S 0                                      Datum der Datenänderung   
d cdate           S              8S 0                                      Datum der Attributänderung
 
Datenstromdatei füllen                                                                            
c                   
Eval      StmF =                                                                 
c                              '/QDLS/ORDNER/test.txt'                                       
 
String mit Null terminieren                                                                       
c                   
Eval      StmF = %Trim(StmF) + X'00'                                             
 
Felder initialisieren                                       
c                   
Eval      adate = *Zero                    
c                   
Eval      mdate = *Zero                    
c                   
Eval      cdate = *Zero                    
 
Funktion 'stat' aufrufen                                    
c                   
If        stat(%Addr(StmF) :               
c                                  %Addr(stat_ds))             
c                             <> - 1                           
 
Datum des letzten Zugriffs                                  
c                   CallP     localtime_r
(%Addr(st_atime) :    
c                                         %Addr(tm_ds))        
c                   Eval      adate tm_mday +                
c                                    ((tm_mon 1) * 100) +    
c                                    ((tm_year 1900) * 10000)
 * 
Datum der Datenänderung                                     
c                   CallP     localtime_r
(%Addr(st_mtime) :    
c                                         %Addr(tm_ds))        
c                   Eval      mdate tm_mday +                
c                                    ((tm_mon 1) * 100) +    
c                                    ((tm_year 1900) * 10000)
 * 
Datum der Attributänderung                                  
c                   CallP     localtime_r
(%Addr(st_ctime) :    
c                                         %Addr(tm_ds))        
c                   Eval      cdate tm_mday +                
c                                    ((tm_mon 1) * 100) +    
c                                    ((tm_year 1900) * 10000)
c                   EndIf                                      
 * 
Programmende                                                
c                   
Eval      *INLR = *On