Registers a file type for I/O type add-ons.
GSErrCode ACAPI_Register_FileType (
Int32 refCon,
GSType ftype,
GSType fcreator,
const char* extname,
short iconResID,
short descStrResID,
short descStrResItemID,
API_IOMethod methodFlags
);
Parameters
- refCon
- [in] An arbitrary number which identifies this file type within the add-on.
- ftype
- [in] Macintosh file type (e.g. ‘TEXT’).
- fcreator
- [in] Creator on Macintosh (e.g. ‘GSAC’ for Archicad).
- extname
- [in] The extension used on Windows (e.g. “txt”).
- iconResID
- [in] An optional icon resource ID. This icon appears in the Open/Save dialogs on the Macintosh.
- descStrResID
- [in] The resource ID of the resource containing the description of the file type.
- descStrResItemID
- [in] The item ID within the resource of the item containing the description of the file type, or 0 when specifying MIME type as well (see Remarks).
- methodFlags
- [in] Flags describing the Open/Save dialogs to add this file type to (see Remarks).
Return Values
NoError- The function has completed with success.
For other common API errors see the API Errors document.
Remarks
This function should be called from the RegisterInterface routine in your add-on. You can register more than one file type from the same add-on, appearing in different menus of the server application.
The supplied refCon parameter should be the same in the ACAPI_Install_FileTypeHandler function, which you have to call from your Initialize routine.
The methodFlags parameter defines which dialogs’ file type popup should contain the registered file type:
Flag File Dialog Open2DSupportedOpen as 2D Merge2DSupportedMerge OpenLibPartSupportedOpen Library Item SaveAs2DSupportedSave as 2D SaveAs3DSupportedSave as 3D SaveAsFlySupportedCreate Fly-Through/Sun Study Import2DDrawingSupportedImport as Drawing
From API v4.2 you have the possibility to register the MIME type for the file as well. MIME (Multipurpose Internet Mail Extension) types are commonly accepted identifiers for certain media types. Specifying the MIME type makes the file format identification more accurate in the File Type Manager.
If you decide to use this feature, you can do this in the following way:
- in the GRC file the string resource that describes the file format must contain two items:
- the descriptive name of the file format (e.g. “DWF File”)
- the assigned MIME type (e.g. “model/vnd.dwf”)
- in the
descStrResItemIDparameter of theACAPI_Register_FileTypefunction you must pass 0
Example
In the localizable GRC file:
'STR#' 32500 "File Type descriptions" { /* [ 1] */ "DWF File" /* [ 2] */ "model/vnd.dwf" }
In the RegisterInterface function:
//------------------------------------------------------ // Interface definitions //------------------------------------------------------ GSErrCode __ACENV_CALL RegisterInterface (void) { GSErrCode err; err = ACAPI_Register_FileType (1, 'GSAC', ' DWF', "dwf", 0, 32500, 0, SaveAs2DSupported + Open2DSupported + Merge2DSupported + Import2DDrawingSupported); return err; } // RegisterInterface
Requirements
- Version: API 4.1 or later
- Header: ACAPinc.h