/* AmigaE Datatypes ghh 2021 */
/* Zjisteni informaci o souboru pomoci datatypu */
/* verze s argumentem (nazev souboru) pri spusteni z cli */
MODULE 'dos/dos' /* ACCESS_READ */
MODULE 'datatypes','datatypes/datatypes','datatypes/datatypesclass'
MODULE 'iffparse','libraries/iffparse' /* IdtoStr */
ENUM ERR_NONE,ERR_DTLIB,ERR_IFLIB
PROC main() HANDLE
DEF fajl,lock,buffer[8]:STRING
DEF dth=NIL:PTR TO datatypeheader,dtn:PTR TO datatype
IF arg[]=0 /* pokud neni argument */
WriteF('No Args!\n')
JUMP konec /* skocit na konec */
ENDIF
fajl:=arg /* cesta k souboru */
IF (datatypesbase:=OpenLibrary('datatypes.library',39))=NIL THEN Raise(ERR_DTLIB)
IF (iffparsebase:=OpenLibrary('iffparse.library',39))=NIL THEN Raise(ERR_IFLIB)
WriteF(' Soubor:\s\n',fajl)
IF (lock:=Lock(fajl, ACCESS_READ)) /* Lock na file potrebuje ObtainDataTypeA */
IF (dtn:=ObtainDataTypeA(DTST_FILE,lock,NIL)) /* zjisteni typu souboru */
dth:=dtn.header
WriteF('Description:\s\n',dth.name)
WriteF(' Base Name:\s\n',dth.basename)
WriteF(' Pattern:\s\n',dth.pattern)
WriteF(' Group:\s\n',GetDTString(dth.groupid))
WriteF(' Type:\s\n',GetDTString((dth.flags AND DTF_TYPE_MASK) + DTMSG_TYPE_OFFSET))
WriteF(' ID:\s\n',IdtoStr(dth.id, buffer))
ReleaseDataType(dtn) /* po precteni uvolnit */
ENDIF
UnLock(lock) /* nakonec uvolnit Lock */
ENDIF
konec:
EXCEPT DO
IF datatypesbase THEN CloseLibrary(datatypesbase)
IF iffparsebase THEN CloseLibrary(iffparsebase)
SELECT exception /* hlaseni chyb */
CASE ERR_DTLIB
WriteF('Error: Could not open datatypes.library\n')
CASE ERR_IFLIB
WriteF('Error: Could not open iffparse.library\n')
ENDSELECT
ENDPROC
|