home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.1 (Developer) [x86] / NeXT Step 3.1 Intel dev.cdr.dmg / NextDeveloper / Headers / indexing / IXFileFinder.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-29  |  7.7 KB  |  215 lines

  1. /*
  2. IXFileFinder.h
  3. Copyright 1991, NeXT Computer, Inc.
  4. */
  5.  
  6. #import <objc/hashtable.h>
  7. #import    <machkit/reference.h>
  8.  
  9. #import    "IXPostingList.h"
  10.  
  11. @class IXBTree, IXFileFinder, IXFileRecord;
  12.  
  13. typedef struct             {
  14.     unsigned            recordNumber;
  15.     unsigned            dateModified;
  16. } IXFileRegistration;
  17.  
  18. @protocol IXFileFinderQueryAndUpdate
  19.  
  20. - (const char *)rootPath; // returns the root path
  21.  
  22. // Returns the file finder's record manager.  The file finder forwards all 
  23. // unrecognized messages to its record manager.
  24. - recordManager;
  25.  
  26. - (char *)attributeNames; // returns the names of indexed attributes
  27.  
  28. - clean; // removes stale information from the index
  29. - reset; // removes everything from the index
  30.  
  31. // updates the index in the caller's thread, starting at the supplied path.
  32. - updateIndexAtPath:(const char *)path forSender:aSender;
  33.  
  34. - (BOOL)isUpdating; // true when asynchronous updating is in progress
  35. - resumeUpdating; // resumes asynchronous updating
  36. - suspendUpdating; // suspends asynchronous updating
  37.  
  38. - stopQueryForSender:aSender; // stops a recursive descent in progress
  39. - (IXPostingList *)performQuery:(const char *)query 
  40.     atPath:(const char *)path forSender:aSender;
  41.  
  42. // This method returns the registry used by the file finder.  The keys are 
  43. // relative file names, and the values are instances of the IXFileRegistration 
  44. // structure defined above.  The registry should be considered read only.
  45. - (IXBTree *)registry;
  46.  
  47. @end
  48.  
  49. @interface Object(IXFileFinderSender)
  50.  
  51. // Called with the list of results from querying the index.
  52. - fileFinder:(IXFileFinder *)aFinder 
  53.     didFindList:(IXPostingList *)aList;
  54.  
  55. // Called during recursive descent for each file that satisfies the query.
  56. - fileFinder:(IXFileFinder *)aFinder 
  57.     didFindFile:(IXFileRecord *)anObject;
  58.  
  59. // Called during recursive descent for each file visited before parsing the 
  60. // file contents or testing for conformance to the query.  This method returns 
  61. // its second argument, or a new file record that replaces its second argument.
  62. - fileFinder:(IXFileFinder *)aFinder 
  63.     willAddFile:(IXFileRecord *)anObject;
  64.  
  65. // Called during recursive descent for each file visited after parsing and 
  66. // testing, but before adding the file to the index.  The file record contains 
  67. // a full complement of attribute bindings at this point.  This method returns 
  68. // its second argument, or a new file record that replaces its second argument.
  69. - fileFinder:(IXFileFinder *)aFinder 
  70.     didAddFile:(IXFileRecord *)anObject;
  71.  
  72. @end
  73.  
  74. @protocol IXFinderControl
  75.  
  76. // Returns self, or nil to deny enumeration of the named directory.  
  77. - fileFinder:(IXFileFinder *)aFinder willEnumerate:(char *)filename;
  78.  
  79. // Called to allow subsidiary file finders to be recursively queried.
  80. - (IXPostingList *)fileFinder:(IXFileFinder *)aFinder 
  81.     didPerform:(char *)query atPath:(char *)path forSender:aSender;
  82.  
  83. @end
  84.  
  85. @protocol IXFileFinderConfiguration
  86.  
  87. // These methods manage the list of parsers used by a file finder.  The list 
  88. // is searched for a parser that understands the type of the file being parsed.
  89.  
  90. - getAttributeParsers:(List *)aList;
  91. - setAttributeParsers:(List *)aList;
  92.  
  93. // The following methods read and write ignored types using strings.
  94.  
  95. - (char *)ignoredTypes; // returns the list of ignored types
  96. - setIgnoredTypes:(const char *)types; // sets the list of ignored types
  97.  
  98. // The following methods read and write ignored types using streams.
  99.  
  100. - readIgnoredTypes:(NXStream *)aStream;
  101. - writeIgnoredTypes:(NXStream *)aStream;
  102.  
  103. // The following methods read and write ignored types using files.
  104.  
  105. - readIgnoredTypesFromFile:(const char *)filename;
  106. - writeIgnoredTypesToFile:(const char *)filename;
  107.  
  108. // The following methods read and write ignored names using strings.
  109.  
  110. - (char *)ignoredNames; // returns the list of ignored names
  111. - setIgnoredNames:(const char *)names; // sets the list of ignored names
  112.  
  113. // The following methods read and write ignored names using streams.
  114.  
  115. - readIgnoredNames:(NXStream *)aStream;
  116. - writeIgnoredNames:(NXStream *)aStream;
  117.  
  118. // The following methods read and write ignored names using files.
  119.  
  120. - readIgnoredNamesFromFile:(const char *)filename;
  121. - writeIgnoredNamesToFile:(const char *)filename;
  122.  
  123. // N.B.: the hidden file policy is not preserved across archiving 
  124. // or across closing the store.  it defaults to NO at initialization.
  125.  
  126. - (BOOL)considersHiddenFiles; // returns hidden file policy
  127. - setConsidersHiddenFiles:(BOOL)flag; // sets hidden file policy
  128.  
  129. - (BOOL)crossesDeviceChanges; // returns device crossing policy
  130. - setCrossesDeviceChanges:(BOOL)flag; // sets device crossing policy
  131.  
  132. - (BOOL)followsSymbolicLinks; // returns symbolic link policy
  133. - setFollowsSymbolicLinks:(BOOL)flag; // sets symbolic link policy
  134.  
  135. - (BOOL)generatesDescriptions; // returns description generation policy
  136. - setGeneratesDescriptions:(BOOL)flag; // sets description generation policy
  137.  
  138. - (BOOL)updatesAutomatically; // returns automatic update policy
  139. - setUpdatesAutomatically:(BOOL)flag; // sets automatic update policy
  140.  
  141. - (BOOL)scansForModifiedFiles; // returns file scanning policy
  142. - setScansForModifiedFiles:(BOOL)flag; // sets file scanning policy
  143.  
  144. - (BOOL)removesAutomatically; // sets the automatic removal policy
  145. - setRemovesAutomatically:(BOOL)aBoolean; // returns automatic removal policy
  146.  
  147. - (unsigned)commitDelay; // returns the commit delay in seconds
  148. - setCommitDelay:(unsigned)seconds; // sets the commit delay for updating
  149.  
  150. - (id <IXFinderControl>)finderControl; // sets the controller for recursion
  151. - setFinderControl:(id <IXFinderControl>)anObject; // returns the controller
  152.  
  153. @end
  154.  
  155. // an instance of this class manages the inversion of a single rootPath tree in the file system.  multiple queries may be run concurrently with updating.
  156.  
  157. @interface IXFileFinder: Object <NXReference, IXNameAndFileAccess, IXFileFinderQueryAndUpdate, IXFileFinderConfiguration, IXAttributeBinding>
  158. {
  159.     struct FinderRecord    *_finderRecord;
  160.     unsigned        references; // the reference count
  161.     List        *attributeParsers; // the list of attribute parsers
  162.     id            recordManager; // the supporting record manager
  163.     NXHashTable        *ignoredNames; // table of ignored names
  164.     NXHashTable        *ignoredTypes; // table of ignored types
  165.     char        *rootPath; // the root path
  166.     unsigned        commitDelay; // transaction commit delay in seconds
  167.     struct        {
  168.     unsigned    crossesDeviceChanges:1; // crosses device changes
  169.     unsigned    followsSymbolicLinks:1; // follows symbolic links
  170.     unsigned    generatesDescriptions:1; // generates descriptions
  171.     unsigned    updatesAutomatically:1; // queries request updates
  172.     unsigned    scansForModifiedFiles:1; // scans for modified files
  173.     unsigned    removesAutomatically:1; // scans for removed files
  174.     unsigned    considersHiddenFiles:1; // considers hidden files
  175.     }             booleanOptions;
  176. }
  177.  
  178. // Returns the store, e.g., [[client store] startTransaction].
  179. - (IXStore *)store;
  180.  
  181.  
  182. // The following methods are analagous to the initialization methods defined  
  183. // by the IXBlockAndStoreAccess and IXNameAndFileAccess protocols.  The path 
  184. // supplied to the methods is the root of the file system subtree managed by 
  185. // the file finder.  A file finder may be rerooted simply by opening it with a 
  186. // new root path.  If the protocol methods are used, then the current working 
  187. // directory is used as the default root path parameter.
  188.  
  189. - initInStore:(IXStore *)aStore 
  190.     atPath:(const char *)path;
  191. - initFromBlock:(unsigned)block inStore:(IXStore *)aStore 
  192.     atPath:(const char *)path;
  193.  
  194. - initWithName:(const char *)name inFile:(const char *)filename 
  195.     atPath:(const char *)path;
  196. - initFromName:(const char *)aName inFile:(const char *)filename 
  197.     forWriting:(BOOL)flag atPath:(const char *)path;
  198.  
  199. @end
  200.  
  201. #ifdef KANJI
  202.  
  203. #define IX_NOTDEF_ENCODING    0
  204. #define IX_NEXTSTEP_ENCODING    1
  205. #define IX_NJE_ENCODING    2
  206.  
  207. @interface IXFileFinder(QueryEncoding)
  208.  
  209. - (unsigned)queryEncoding;
  210. - setQueryEncoding:(unsigned)encoding;
  211.  
  212. @end
  213.  
  214. #endif KANJI
  215.