recurse.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. ** IterateDirectory: File Manager directory iterator routines.
  3. **
  4. ** by Jim Luther
  5. **
  6. ** File: IterateDirectory.h
  7. **
  8. ** Copyright (c) 1995-1998 Jim Luther and Apple Computer, Inc.
  9. ** All rights reserved.
  10. **
  11. ** You may incorporate this sample code into your applications without
  12. ** restriction, though the sample code has been provided "AS IS" and the
  13. ** responsibility for its operation is 100% yours.
  14. **
  15. ** IterateDirectory is designed to drop into the MoreFiles sample code
  16. ** library I wrote while in Apple Developer Technical Support
  17. */
  18. #ifndef __RECURSEDIRECTORY__
  19. #define __RECURSEDIRECTORY__
  20. #include <Types.h>
  21. #include <Files.h>
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /*****************************************************************************/
  26. pascal OSErr RecurseDirectory(short vRefNum,
  27. long dirID,
  28. ConstStr255Param name,
  29. unsigned short maxLevels );
  30. /* Iterate (scan) through a directory's content.
  31. The IterateDirectory function performs a recursive iteration (scan) of
  32. the specified directory and calls your IterateFilterProc function once
  33. for each file and directory found.
  34. The maxLevels parameter lets you control how deep the recursion goes.
  35. If maxLevels is 1, IterateDirectory only scans the specified directory;
  36. if maxLevels is 2, IterateDirectory scans the specified directory and
  37. one subdirectory below the specified directory; etc. Set maxLevels to
  38. zero to scan all levels.
  39. The yourDataPtr parameter can point to whatever data structure you might
  40. want to access from within the IterateFilterProc.
  41. vRefNum input: Volume specification.
  42. dirID input: Directory ID.
  43. name input: Pointer to object name, or nil when dirID
  44. specifies a directory that's the object.
  45. maxLevels input: Maximum number of directory levels to scan or
  46. zero to scan all directory levels.
  47. iterateFilter input: A pointer to the routine you want called once
  48. for each file and directory found by
  49. IterateDirectory.
  50. yourDataPtr input: A pointer to whatever data structure you might
  51. want to access from within the IterateFilterProc.
  52. Result Codes
  53. noErr 0 No error
  54. nsvErr -35 No such volume
  55. ioErr -36 I/O error
  56. bdNamErr -37 Bad filename
  57. fnfErr -43 File not found
  58. paramErr -50 No default volume or iterateFilter was NULL
  59. dirNFErr -120 Directory not found or incomplete pathname
  60. or a file was passed instead of a directory
  61. afpAccessDenied -5000 User does not have the correct access
  62. afpObjectTypeErr -5025 Directory not found or incomplete pathname
  63. __________
  64. See also: RecurseFilterProcPtr, FSpRecurseDirectory
  65. */
  66. /*****************************************************************************/
  67. pascal OSErr FSpRecurseDirectory(const FSSpec *spec,
  68. unsigned short maxLevels);
  69. /* Iterate (scan) through a directory's content.
  70. The FSpIterateDirectory function performs a recursive iteration (scan)
  71. of the specified directory and calls your IterateFilterProc function once
  72. for each file and directory found.
  73. The maxLevels parameter lets you control how deep the recursion goes.
  74. If maxLevels is 1, FSpIterateDirectory only scans the specified directory;
  75. if maxLevels is 2, FSpIterateDirectory scans the specified directory and
  76. one subdirectory below the specified directory; etc. Set maxLevels to
  77. zero to scan all levels.
  78. The yourDataPtr parameter can point to whatever data structure you might
  79. want to access from within the IterateFilterProc.
  80. spec input: An FSSpec record specifying the directory to scan.
  81. maxLevels input: Maximum number of directory levels to scan or
  82. zero to scan all directory levels.
  83. iterateFilter input: A pointer to the routine you want called once
  84. for each file and directory found by
  85. FSpIterateDirectory.
  86. yourDataPtr input: A pointer to whatever data structure you might
  87. want to access from within the IterateFilterProc.
  88. Result Codes
  89. noErr 0 No error
  90. nsvErr -35 No such volume
  91. ioErr -36 I/O error
  92. bdNamErr -37 Bad filename
  93. fnfErr -43 File not found
  94. paramErr -50 No default volume or iterateFilter was NULL
  95. dirNFErr -120 Directory not found or incomplete pathname
  96. afpAccessDenied -5000 User does not have the correct access
  97. afpObjectTypeErr -5025 Directory not found or incomplete pathname
  98. __________
  99. See also: RecurseFilterProcPtr, RecurseDirectory
  100. */
  101. /*****************************************************************************/
  102. #endif /* __RECURSEDIRECTORY__ */