GetFInfo
GetFInfo Obtain file type, creator, icon position, etc.
#include <Files.h> File Manager
OSErr GetFInfo( fileName, vRefNum, fndrInfo );
Str255 fileName ; address of length-prefixed full or partial name
short vRefNum ; volume or working directory reference
FInfo *fndrInfo ; address of a 16-byte FInfo structure
returns Error Code; 0=no error
GetFInfo obtains a copy of the 16-byte packet of de scriptive information
maintained for the Finder. This includes the file's type, the signature of its
creator, Finder flags (such as whether the icon is displayed or is actually on
the desktop), and the display position of the file's icon within its folder
( window).
fileName is the address of a length-prefixed, pascal-style string containing
the name of the file of interest. It may be a partial or full pathname,
depending upon the value of vRefNum .
vRefNum is the reference number of the volume or working directory that
contains the file or directory fileName. 0 indicates the default
volume.
fndrInfo is the address of a 16-byte FInfo structure. Upon return, it is
filled with file-specific information used by the Finder.
Returns: an operating system Error Code. It will be one of:
noErr (0) No error
bdNamErr (-37) Bad name
extFSErr (-58) External file system
fnfErr (-43) File not found
ioErr (-36) I/O error
paramErr (-50) No default volume

Notes: The meaning of the bits in the fdFlags field of the FInfo structure has
changed since System 6.x. Be sure to check the FInfo structure to be sure
that the meaning of the bit that you are checking has not changed. For
instance, there is no longer a bit in the fdFlags field which indicates
whether or not a file is locked. To determine this information call
PBGetFInfo and examine the ioFlAttrib field.
GetFInfo is a functional subset of the low-level PBGetFInfo call ( which
allows you to examine the file's date/time information as well as the
Finder-specific data).
The FInfo structure maintains the primary information used by the Finder
in locating the icon to display, where to display it and which application to
run when its icon is double-clicked. It is the same information as in the
ioFlFndrInfo field of the FileParam structure, which is passed to custom
"file filters" used in the Standard File Package (see SFGetFile).
Additional Finder information is maintained in an FXInfo structure, which
can be obtained via PBGetCatInfo. Use SetFInfo, PBSetFInfo, or
PBSetCatInfo to modify the Finder information (and other information
about a file).
If your application rewrites files by deleting the original and creating a
new one, you should maintain the position on the file's icon within its folder.
Example
#include <Files.h>
short rc;
char *tcp = (char *) &fi.fdType;
char *ccp = (char *) &fi.fdCreator;
rc=GetFInfo( "\pHardDisk:Ltrs:Smith", 0, &fi );
if ( rc ) { /* . . . handle the error . . . */ }
printf ("File Type: '%ld' File Creator: '%ld' \n", tcp[0], ccp[0] );