How to verify if there is a datatypes class installed to open specific dataype, without opening it first!

3 posts / 0 new
Last post
broadblues
broadblues's picture
Offline
Last seen: 2 years 6 months ago
Joined: 2012-05-02 21:48
How to verify if there is a datatypes class installed to open specific dataype, without opening it first!
By using ObtainDataType() I can easily find the group, basename etc of the datatype of an object, but how do I verify if there is class available to handle it? For example ObtainDatatype() will return System binary for an executable but if I have no binary.datatype installed I will not be able to open it. I don't wish to 'test by opening' as some files in the datatset might be large and so take quite a while to process a long list file just to rject the one or two that might not be openable.
broadblues
broadblues's picture
Offline
Last seen: 2 years 6 months ago
Joined: 2012-05-02 21:48
I think I found a solution in
I think I found a solution in the following, I pass the dth_BaseName filed to the following.
  1. BOOL VerifyDataType(STRPTR basename)
  2. {
  3. TEXT pattern[] = "DataTypes/%s.datatype";
  4. BOOL result = FALSE;
  5.  
  6. if(basename)
  7. {
  8. STRPTR fullname = MVAllocVec(sizeof(pattern) + strlen(basename) + 1);
  9. if(fullname)
  10. {
  11. struct Library *tempbase;
  12. SNPrintf(fullname,sizeof(pattern) + strlen(basename) +1, pattern, basename);
  13. if((tempbase = OpenLibrary(fullname,0L)))
  14. {
  15. result = TRUE;
  16. CloseLibrary(tempbase);
  17. }
  18. }
  19. }
  20. return result;
  21. }
Is there a better solution?
broadblues
broadblues's picture
Offline
Last seen: 2 years 6 months ago
Joined: 2012-05-02 21:48
This solution appears to
This solution appears to cause a crash in ascii.datatype (on subsequent usage to create a DTObject) when invoked before any datatype has been accessed, so does amyone have any suggestions as to better more system friendly method?
Log in or register to post comments