Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
107 user(s) are online (61 user(s) are browsing Forums)

Members: 0
Guests: 107

more...

Headlines

 
  Register To Post  

Datatype descriptors
Supreme Council
Supreme Council


See User information
(I don't have the sdk at hand where I'm at now)

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.

BOOL IsFileOfType(STRPTR filepath, STRPTR descriptorpath);

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Datatype descriptors
Just can't stay away
Just can't stay away


See User information
@orgin

I use the following:
http://aminet.net/package/dev/misc/MakeDT-1.3

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.

Go to top
Re: Datatype descriptors
Supreme Council
Supreme Council


See User information
@salass00

Hmm okey, seems like I wont be able to do what I want with it then.

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Datatype descriptors
Amigans Defender
Amigans Defender


See User information
@orgin

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.

Go to top
Re: Datatype descriptors
Supreme Council
Supreme Council


See User information
@Chris

Yeah but that requires that the descriptor is registered in the datatype system? I need to keep my descriptors outside the existing datatype system.

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Datatype descriptors
Quite a regular
Quite a regular


See User information
@orgin

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...

Back to a quiet home... At last
Go to top
Re: Datatype descriptors
Supreme Council
Supreme Council


See User information
@abalaban

Can you provide an example for such an arexx call?

Btw, is it easy to add new identifiers to deficons? For example, adding an identifier for protracker modules.

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Datatype descriptors
Quite a regular
Quite a regular


See User information
@orgin

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.

Back to a quiet home... At last
Go to top
Re: Datatype descriptors
Just can't stay away
Just can't stay away


See User information
@abalaban

Quote:
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
Go to top
Re: Datatype descriptors
Quite a regular
Quite a regular


See User information
@TSK

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 ()

That should be all

Back to a quiet home... At last
Go to top
Re: Datatype descriptors
Amigans Defender
Amigans Defender


See User information
@orgin

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.

Go to top
Re: Datatype descriptors
Supreme Council
Supreme Council


See User information
@Chris

Quote:

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).


That works like a charm actually, thanks!

Tiny code example:
#include <workbench/icon.h>

...
 
char buf[256];
 
IIcon->GetIconTags(path,
  
ICONGETA_IdentifyOnly,TRUE,
  
ICONGETA_IdentifyBufferbufTAG_DONE);

 
fprintf(stderr"Filetype: %s\n",buf);

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Datatype descriptors
Supreme Council
Supreme Council


See User information
@Chris

Btw, it doesn't seem to work in 4.0 though even if it says v52 in the include. (4.0 has 52.2). My 4.1 has 52.6.

Weird that it's not a version change when adding a new function.

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Datatype descriptors
Amigans Defender
Amigans Defender


See User information
@orgin
Quote:
Weird that it's not a version change when adding a new function.

ICONGETA_IdentifyBuffer was added in icon.library 52.6. Sorry it isn't documented properly.

ExecSG Team Lead
Go to top
Re: Datatype descriptors
Just can't stay away
Just can't stay away


See User information
Quote:
ICONGETA_IdentifyBuffer

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
Go to top
Re: Datatype descriptors
Amigans Defender
Amigans Defender


See User information
@TSK

There's another tag that does that - ICONGETA_Format or something like that.

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project