home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C++ / Snippets / Scan Folder 1.3 / File Scanner Source / Scan.h < prev   
Encoding:
Text File  |  1994-05-04  |  4.0 KB  |  82 lines  |  [TEXT/KAHL]

  1.  
  2. // FILE    : Scan.h
  3. // NAME    : Scan Folder Utilities
  4. // VERSION : 1.3
  5. // DATE    : Dec. 29, 1993
  6. // UPDATE  : Feb. 21, 1994
  7. // AUTHOR  : Hiep Dam, 3G Software
  8. // CONTACT : Via America Online at StarLabs, or
  9. //             2226 Parkside Ave. #302, Los Angeles, CA 90031
  10. // STATUS  : This code is freeware and is in the public domain. Feel free to use it
  11. //             if you find it useful (it would be nice if you gave me some credit,
  12. //             though  ;)
  13.  
  14. // ----------------------------------------------------------------
  15.  
  16. // ScanFolder.
  17. // Scan for the given folder, starting at startDirID, and then scan the contents
  18. // of the folder for any files. Any files found will be appended to the FSSpec array
  19. // you pass to it. Note that the FSSpec records ScanFolder creates (and all the other
  20. // Scan functions as well) do not prefix the file's name with a ":". This is so
  21. // that you can display the file name, do other things with it first, etc. If you
  22. // wish, you can have the colons prefixed. Luckily you don't have to do this yourself;
  23. // just call PrefixColon for one FSSpec, or PrefixColons for an array of FSSpec's.
  24. // I've found that FSpOpenDF and FSpOpenResFile work fine either with or without
  25. // a colon. I'm not sure if it's required before a filename (not pathname). If you
  26. // know, please tell me! (Thanks!)
  27. // If you want ScanFolder to start the scan in the same folder as the application,
  28. // pass nil in the folderName argument, still passing the same startDirID (assuming
  29. // this dirID is the default dir id).
  30. // ScanFolder returns the number of files found.
  31. // Vers 1.3 addendum: scanning routine now works with aliases...
  32.  
  33. short ScanFolder(Str63 folderName, long startDirID, FSSpec *fileArray, short arraySize,
  34.             Boolean resolveAlias = true, Boolean resolveFolderAlias = true);
  35.  
  36.  
  37. // ScanFolderByType.
  38. // Much like ScanFolder, but restrict the scan to files of a particular type, i.e.
  39. // scan only for "TEXT" files, "PICT" files, "sfil" files, etc. Pass the file
  40. // type in "restriction".
  41. // ScanFolderByType returns the number of files found with the given type located
  42. // in the folder folderName.
  43. short ScanFolderByType(Str63 folderName, long startDirID, OSType restriction, FSSpec *fileArray,
  44.             short arrraySize, Boolean resolveAlias = true, Boolean resolveFolderAlias = true);
  45.  
  46.  
  47. // ScanFolderByCreator.
  48. // Exactly like ScanFolderByType, except do it by creator, i.e. Think's "KAHL" or
  49. // Teachtext's "ttxt", etc.
  50. short ScanFolderByCreator(Str63 folderName, long startDirID, OSType restriction, FSSpec *fileArray,
  51.             short arraySize, Boolean resolveAlias = true, Boolean resolveFolderAlias = true);
  52.  
  53.  
  54. // ScanFolderSpecific.
  55. // A combination of ScanFolderByCreator and ScanFolderByType.
  56. short ScanFolderSpecific(Str63 folderName, long startDirID, OSType fType, OSType fCreator, FSSpec *fileArray,
  57.             short arraySize, Boolean resolveAlias = true, Boolean resolveFolderAlias = true);
  58.  
  59.  
  60. // ScanFolderByName.
  61. // Actually a search routine.
  62. // Search for the file with the given filename within the folder folderName.
  63. // The file found will be placed in fileArray[0]. ScanFolderByName will only search
  64. // for the file once; once it finds the file, it exits, so any files with duplicate
  65. // names that may be in nested folders within folder folderName won't be found.
  66. short ScanFolderByName(Str63 folderName, long startDirID, Str63 fileName, FSSpec *fileArray,
  67.             short arraySize, Boolean resolveAlias = true, Boolean resolveFolderAlias = true);
  68.  
  69.  
  70. // GetFolderDirID.
  71. // If for any reason you need the directory id of a folder, you can use this function.
  72. // Else, you'll probably have no use for it; it's used primarily by the above Scan
  73. // routines (they use it to search for the folder you specify to them).
  74. long GetFolderDirID(Str63 folderName, long startDirID);
  75.  
  76.  
  77. // PrefixColon(s).
  78. // Prefix file names in a FSSpec record with a colon ":". Note that
  79. // these routines do no error-checking, so if the file already has a
  80. // colon prefixed to it, these routines will prefix anyway.
  81. void PrefixColon(FSSpec *fileSpec);
  82. void PrefixColons(FSSpec *fileArray, short arraySize);