2 Copyright © 2004, The AROS Development Team. All rights reserved.
6 #include <proto/datatypes.h>
7 #include <datatypes/datatypes.h>
18 #define ERROR_HEADER "Identify"
20 /*** Prototypes *************************************************************/
21 int identify(CONST_STRPTR filename
, BOOL verbose
);
22 CONST_STRPTR
gid2string(ULONG gid
);
24 /*** Functions **************************************************************/
28 struct RDArgs
*rdargs
= NULL
;
29 IPTR args
[ARG_COUNT
] = { 0 };
31 if ((rdargs
= ReadArgs("FILE/M/A,VERBOSE/S", args
, NULL
)) != NULL
)
33 CONST_STRPTR
*files
= (CONST_STRPTR
*) args
[ARG_FILE
], file
;
35 while ((file
= *files
++) != NULL
)
37 if (identify(file
, args
[ARG_VERBOSE
]) != RETURN_OK
)
47 PrintFault(IoErr(), ERROR_HEADER
);
54 int identify(CONST_STRPTR filename
, BOOL verbose
)
57 BPTR lock
= Lock(filename
, ACCESS_READ
);
61 struct DataType
*dt
= ObtainDataType(DTST_FILE
, lock
, TAG_DONE
);
64 struct DataTypeHeader
*dth
= dt
->dtn_Header
;
71 filename
, gid2string(dth
->dth_GroupID
), dth
->dth_Name
76 ULONG gid
= AROS_LONG2BE(dth
->dth_GroupID
),
77 id
= AROS_LONG2BE(dth
->dth_ID
);
82 "Type: %s/%s\t(GID: %.4s, ID: %.4s)\n"
83 "DT Basename: %s\n\n",
84 filename
, gid2string(dth
->dth_GroupID
), dth
->dth_Name
,
85 (CONST_STRPTR
) &gid
, (CONST_STRPTR
) &id
,
92 FPrintf(Error(), ERROR_HEADER
": Could not obtain datatype for file.\n");
100 PrintFault(IoErr(), ERROR_HEADER
);
107 CONST_STRPTR
gid2string(ULONG gid
)
111 case GID_SYSTEM
: return "System";
112 case GID_TEXT
: return "Text";
113 case GID_DOCUMENT
: return "Document";
114 case GID_SOUND
: return "Sound";
115 case GID_INSTRUMENT
: return "Instrument";
116 case GID_MUSIC
: return "Music";
117 case GID_PICTURE
: return "Picture";
118 case GID_ANIMATION
: return "Animation";
119 case GID_MOVIE
: return "Movie";
120 default: return NULL
;