Important: The information in this document is obsolete and should not be used for new development.
Identifying Files
Once Macintosh Easy Open knows the types of files from and to which your extension can translate, it might call your extension to determine whether your extension can translate a particular file. This further check is necessary because some documents might have file types that are not specific enough for translation purposes. For example, a document imported from a different operating system might have a file type of'TEXT'. Your translation extension might be able to determine, however, that the file actually contains SurfWriterPC data and hence deserves special format conversion treatment.When your translation extension is called with the
kTranslateIdentifyFilerequest code, your extension should identify the particular document. TheTranslateEntryextension (shown in Listing 7-5 on page 7-25) dispatches to itsDoIdentifyFilefunction when it receives this request code. Listing 7-7 shows the skeleton of aDoIdentifyFilefunction.Listing 7-7 Identifying file types
FUNCTION DoIdentifyFile (self: ComponentInstance; theDoc: FSSpec; VAR docKind: FileType): ComponentResult; VAR isKnown: Boolean; {indicates whether this extension can identify the file} BEGIN {call an extension-defined routine to do the real work} isKnown := MyIdentifyDocument(theDoc, docKind); IF isKnown THEN DoIdentifyFile := noErr ELSE DoIdentifyFile := noTypeErr; END;Some documents can be identified simply by inspecting their file type and creator. Other documents (in particular, those of type'TEXT') might require opening the files and examining their contents to determine whether they can be translated by your extension. If your extension cannot recognize the document type,DoIdentifyFileshould returnnoTypeErr. Otherwise,DoIdentifyFileshould returnnoErr, and thedocKindparameter should be set to the recognized file type.
You should be aware that even if your extension identifies a particular document as one that it can translate, Macintosh Easy Open might not in fact call your extension to do the translation.
- Note
- Your
DoIdentifyFilefunction should not return'TEXT'as a file type unless it's certain that the document consists of plain, unformatted ASCII text.
 
  
  
 