home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Snippets / LocateFile / LocateFile.h < prev    next >
Encoding:
Text File  |  1994-11-11  |  1.5 KB  |  38 lines  |  [TEXT/MMCC]

  1. // View this file in Geneva 9 with 4 space tabs.
  2. // This code was written by François Pottier (pottier@dmi.ens.fr) and compiled with CodeWarrior 4.5. You can use it freely.
  3. // The code assumes System 7.
  4.  
  5. #pragma once
  6.  
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10.  
  11. /*
  12. Locate a file based on its type and creator. It is safer than using a file name : users have this distressing habit of renaming files.
  13.  
  14. The routine looks for the file in the system subfolder specified by 'where', typically the Preferences folder or the Extensions folder.
  15. The first file with the corresponding type and creator is considered a match.
  16.  
  17. If the file is found, its FSSpec is returned and 'wasAbsent' is set to false.
  18. If the file doesn't exist, it is (optionally) created using FSpCreateResFile and the supplied type, creator and name. 'wasAbsent' is set
  19. to true. An FSSpec is also returned. If desired, the routine can copy the application's 'vers' 2 resource into the file. This is useful
  20. for preferences files.
  21.  
  22. If you don't care about 'wasAbsent', pass NULL.
  23. */
  24.  
  25. OSErr LocateFile (    OSType where,                                // Folder code, to be passed to FindFolder
  26.                 OSType fdType,                            // Desired type and creator
  27.                 OSType fdCreator,
  28.                 short strFileName,                            // 'STR ' resource ID for the default name
  29.                 FSSpec *spec,                                // Resulting file specification
  30.                 Boolean create,                                // If true, the file will be created if missing
  31.                 Boolean *wasAbsent,                        // true if the file didn't exist
  32.                 Boolean copyVers                            // If true, copy our 'vers' 2 resource into the new file
  33.             );
  34.  
  35. #ifdef __cplusplus
  36. }
  37. #endif
  38.