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
kTranslateIdentifyFile
request code, your extension should identify the particular document. TheTranslateEntry
extension (shown in Listing 7-5 on page 7-25) dispatches to itsDoIdentifyFile
function when it receives this request code. Listing 7-7 shows the skeleton of aDoIdentifyFile
function.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,DoIdentifyFile
should returnnoTypeErr
. Otherwise,DoIdentifyFile
should returnnoErr
, and thedocKind
parameter 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
DoIdentifyFile
function should not return'TEXT'
as a file type unless it's certain that the document consists of plain, unformatted ASCII text.