-
attribute anzeigen bei WRKLNK - welcher Befehl?
Hallo all,
habe gerade ein Brett vor dem Kopf.
In der Ansicht von WRKLNK kann man mit "8=Attribute anzeigen" z.B. das Erstellungsdatum anzeigen lassen.
Welcher CL-Befehl steht dahinter - oder nur API ?
Gruß Holger
-
Hiermit wird das Datum der letzten Änderung der Daten zurückgegeben. Möchtest Du das Datum der letzten Änderung der Attribute haben, dann musst Du st_mtime in st_ctime ändern. Möchtest Du das Datum des letzten Zugriffs haben, dann musst Du st_mtime in st_atime ändern. Die Prozedur liefert als Ergebnis das Datum im Format JJJJMMTT.
PHP-Code:
#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
long int RetrieveChangeTime(char *path) {
struct stat info;
struct tm date;
if (stat(path, &info) != 0)
return -1;
else {
localtime_r(&info.st_mtime, &date);
return (date.tm_mday) + ((date.tm_mon + 1) * 100) + ((date.tm_year + 1900) * 10000);
}
}
Frank Hildebrandt
-
Hallo,
wir haben kein C-Compiler auf unserer Maschine,
hat das jemand vielleicht auch in RPGIV?
Trotzdem Danke.
Gruß Holger
-
Der C-Compiler ist bei OS/400 V5RX immer dabei wenn das Produkt 5722-WDS installiert ist. Der Kern der ganzen Sache ist das UNIX-Type API stat(). Dieses API liefert eine komplexe Datenstruktur mit den entsprechenden Informationen zurück. Grundsächtzlich ist es möglich das ganze auch in RPG zu codieren, allerdings ist das alles andere als schön.
Frank Hildebrandt
-
Hallo,
habe folgende Datenstrukturbeschreibung gefunden für RPGIV:
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 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_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
mir fehlt jetzt nur noch der Aufruf für z.B. /QDLS/Ordner/File.txt
Gruß Holger
-
int _stat( const char *path, struct stat *buffer );
-
Hallo Fürchau,
c if stat('/QDLS/ORDNER/test.txt': p_statds) < 0
fehlte mir noch
Gruss Holger
-
Dann hast Du ja die erste Hürde gemeistert. Wenn Du am Datum interessiert bist, dann reicht stat() allerdings nicht aus. Die Felder st_atime, st_mtime, st_ctime enthalten Werte, die mit der Funktion localtime_r() erst konvertiert werden müssen. Und natürlich will auch diese Funktion wieder eine Datenstruktur. Alles in allem ist das Programmieren mit den UNIX-Type API`s in RPG sehr nervig, da die Prototypendefinitionen und die Datenstrukturdefinitionen zumeist selbst erstellt werden müssen. In C sind diese alle bereits da und müssen nur noch mit einem #INCLUDE aufgenommen werden.
Frank Hildebrandt
-
Hier ist das Teil in RPG.
PHP-Code:
h DFTACTGRP(*NO) BNDDIR('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-C 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
Frank Hildebrandt
Similar Threads
-
By stoerfang in forum NEWSboard Programmierung
Antworten: 3
Letzter Beitrag: 24-01-13, 10:27
-
By Rico in forum NEWSboard Programmierung
Antworten: 3
Letzter Beitrag: 06-07-06, 16:25
-
By mikex01 in forum IBM i Hauptforum
Antworten: 9
Letzter Beitrag: 01-06-06, 11:55
-
By becama in forum IBM i Hauptforum
Antworten: 4
Letzter Beitrag: 12-05-06, 19:46
-
By NEich in forum IBM i Hauptforum
Antworten: 5
Letzter Beitrag: 10-05-06, 08:42
Berechtigungen
- Neue Themen erstellen: Nein
- Themen beantworten: Nein
- You may not post attachments
- You may not edit your posts
-
Foren-Regeln
|
Erweiterte Foren Suche
Google Foren Suche
Forum & Artikel Update eMail
AS/400 / IBM i
Server Expert Gruppen
Unternehmens IT
|
Kategorien online Artikel
- Big Data, Analytics, BI, MIS
- Cloud, Social Media, Devices
- DMS, Archivierung, Druck
- ERP + Add-ons, Business Software
- Hochverfügbarkeit
- Human Resources, Personal
- IBM Announcements
- IT-Karikaturen
- Leitartikel
- Load`n`go
- Messen, Veranstaltungen
- NEWSolutions Dossiers
- Programmierung
- Security
- Software Development + Change Mgmt.
- Solutions & Provider
- Speicher – Storage
- Strategische Berichte
- Systemmanagement
- Tools, Hot-Tips
Auf dem Laufenden bleiben
|
Bookmarks