Is there a guide somewhere on how to write the file descriptor files that the datatype system uses?
I'm going to add file type identification to a program and do not want to reinvent the wheel so using the same type of descriptor files as the datatype system would be neat.
Is it possible to use any existing datatype api (library or otherwise) to check if a file matches a descriptor file or does the datatype system hide all that functionality inside it?
Basically what I would like to do is feed a function with a path to a random file and a path to a datatype descriptor file (at a custom location not related to the installed datatypes) and find out if its a match or not.
The ARexx script converts a text file (.dt) that you write into a binary descriptor file that you can put in DEVS:DataTypes. The format of the .dt file is explained in MakeDT.doc and also there are several examples in the archive.
For an example on how to use a function to check for the right filetype you can check the source code from svg_dt.
The function is in the file "descriptor.c". This is compiled into an executable using -nostartfiles and then the name of the executable is specified in the .dt file.
I can't find my example code, but to check the type of a file, you need to use ObtainDataType(). This will return the internal name from the descriptor that handles the file, amongst other things.
The question is why ? Why would you want to have separate descriptors ? Having a system wide datatype database can benefit every other applications, not just yours. Oh and in just all you want is to identify the file type, why not use DefIcons ? DefIcons provides an ARexx port and a command "Identify" taking a filename as argument. you can send an Arexx message from your application and wait for the answer...
If you have ADCD 2.1 look into ":Reference/DevCon/Orlando_1993/Devcon93.1/AREXX/SimpleRexx/SimpleRexx.c" the function SendRexxMsg() you might also want to look at arexx_cl and its AM_EXECUTE method... Basically what you would have to do is searching for DefIcons's arexx port ('DEFICONS') then send this msgport an ARexxMsg with the command 'IDENTIFY "<yourfile>" ' in it and then use the string result ARexx will get back to you.
Adding a new file recognition to DefIcons is done by launching the DefIcons preferences and then setup the recognition parameters.
DefIcons provides an ARexx port and a command "Identify" taking a filename as argument.
Really. I've been looking for that kind of info. Why is nobody ever telling anything to others in this community. (I mean without needing to ask everytime.)
Quote:
wait for the answer...
Maybe that's too slow or complicated in some cases.
@orgin I "reinvented the wheel" and wrote my own routine. I checked from Deficons prefs how certain files are detected. I can give you that code if you think it's useful.
Quote:
is it easy to add new identifiers to deficons?
I think it is.
Rock lobster bit me - so I'm here forever X1000 + AmigaOS 4.1 FE "Anyone can build a fast CPU. The trick is to build a fast system." - Seymour Cray
complicated ? 1) see rexxsyslib/CreateRexxMsg() to create the message, 2) wait on the reply port you specified to CreateRexxMsg(), add 3) call GetMsg() to retreive a struct RexxMsg (rexx/strorage.h) 4) rm_Result against RC_OK, if that's the case rm_Result2 points to a struct RexxArg in which ra_Buff should contain the type name. 5) free your RexxMsg using rexxsyslib/DeleteRexxMsg ()
From C you can also use ICONGETA_IdentifyBuffer (that doesn't seem to be documented in the AutoDoc for GetIconTags() so I'm not sure where I found it) to find the file type from DefIcons (or other global file ID hook).
If you really want to use your own set of Datatype descriptors - again I'd ask "why?" - then it will be a case of reading them yourself with iffparse.library. I don't see the point when datatypes.library will do all this for you, and the additional descriptors will benefit other apps too.
From C you can also use ICONGETA_IdentifyBuffer (that doesn't seem to be documented in the AutoDoc for GetIconTags() so I'm not sure where I found it) to find the file type from DefIcons (or other global file ID hook).
Doh ! I think I saw this in a header file or in autodocs but I got idea that it returns only type of an icon image (like png) or something like that. I thought to test it what kind of info it returns but then I didn't bother for some reason. Thanks to everybody involved to add this functionality into the OS.
Rock lobster bit me - so I'm here forever X1000 + AmigaOS 4.1 FE "Anyone can build a fast CPU. The trick is to build a fast system." - Seymour Cray