PSPDFLibraryFileSystemDataSource


@interface PSPDFLibraryFileSystemDataSource : NSObject <PSPDFLibraryDataSource>

A library data source that indexes all documents in a specified directory. This class automatically will automatically add and remove files from the library based on changes in the directory.

  • Undocumented

    Declaration

    Objective-C

    
    @interface PSPDFLibraryFileSystemDataSource : NSObject <PSPDFLibraryDataSource>
  • Undocumented

    Declaration

    Objective-C

    
    @interface PSPDFLibraryFileSystemDataSource : NSObject <PSPDFLibraryDataSource>
  • Initializes a file system data source.

    Declaration

    Objective-C

    - (nonnull instancetype)
          initWithLibrary:(nonnull PSPDFLibrary *)library
    documentsDirectoryURL:(nonnull NSURL *)URL
          documentHandler:(nullable PSPDFLibraryFileSystemDataSourceDocumentHandler)
                              documentHandler;

    Swift

    init(library: PSPDFLibrary, documentsDirectoryURL URL: URL, documentHandler: PSPDFLibraryFileSystemDataSourceDocumentHandler? = nil)

    Parameters

    library

    The library for which the data source is being created.

    URL

    The URL to the directory whose contents need to be indexed.

    documentHandler

    The block to be called for each document found when traversing the specified directory. Specifying nil for this means makes the data source accept all documents.

    Return Value

    An instance of PSPDFLibraryFileSystemDataSource.

  • The library to which the receiver will be providing data.

    Declaration

    Objective-C

    @property (readonly, nonatomic) PSPDFLibrary *_Nullable library;

    Swift

    weak var library: PSPDFLibrary? { get }
  • The URL containing the documents to be indexed.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSURL *_Nonnull documentsDirectoryURL;

    Swift

    var documentsDirectoryURL: URL { get }
  • The block to be called for each document found when traversing the specified directory. Setting this to nil means makes the receiver accept all documents.

    Declaration

    Objective-C

    @property (readwrite, copy, atomic, nullable)
        PSPDFLibraryFileSystemDataSourceDocumentHandler documentHandler;

    Swift

    var documentHandler: PSPDFLibraryFileSystemDataSourceDocumentHandler? { get set }
  • Options for the directory enumeration. For a list of valid options, see NSDirectoryEnumerationOptions. Defaults to NSDirectoryEnumerationSkipsHiddenFiles.

    Declaration

    Objective-C

    @property (assign, readwrite, atomic)
        NSDirectoryEnumerationOptions directoryEnumerationOptions;

    Swift

    var directoryEnumerationOptions: FileManager.DirectoryEnumerationOptions { get set }
  • Returns a descriptor with some metadata for the document UID, if it has been requested for indexing.

    Warning

    It is possible for the first call to this method to take some time if any I/O is required.

    Declaration

    Objective-C

    - (nullable PSPDFFileIndexItemDescriptor *)
    indexItemDescriptorForDocumentWithUID:(nonnull NSString *)UID;

    Swift

    func indexItemDescriptorForDocument(withUID UID: String) -> PSPDFFileIndexItemDescriptor?

    Parameters

    UID

    The UID of the document for which the descriptor is required.

    Return Value

    A PSPDFFileIndexItemDescriptor object if one was found for the specfied UID, else nil.

  • The document provider to be set to customise the documents to be used by the file system data source. One possible use is to unlock or decrypt documents

    Declaration

    Objective-C

    @property (readwrite, atomic) id<
        PSPDFLibraryFileSystemDataSourceDocumentProvider> _Nullable documentProvider;

    Swift

    weak var documentProvider: PSPDFLibraryFileSystemDataSourceDocumentProvider? { get set }
  • Specifies whether the receiver should only act on changes that are explicitly provided to it, rather than traversing the directory and picking up changes. Set this property to YES if you are able to specify which changes took place in the documents directory of the receiver, thus avoiding the overhead of directory traversal.

    Warning

    Setting this to YES before an initial index means that the PSPDFLibraryDataSource methods will only vend manually added or removed documents.

    Declaration

    Objective-C

    @property (getter=isExplicitModeEnabled, assign, readwrite, atomic)
        BOOL explicitModeEnabled;

    Swift

    var isExplicitModeEnabled: Bool { get set }
  • Notifies the receiver that a document was added or modified to the documents directory. If the URL does not contain the documents directory, then this method does nothing.

    Warning

    If the explicitModeEnabled property is set to NO, this method will assert and crash.

    Declaration

    Objective-C

    - (void)didAddOrModifyDocumentAtURL:(nonnull NSURL *)URL;

    Swift

    func didAddOrModifyDocument(at URL: URL)

    Parameters

    URL

    The URL for the document that was added or modified.

  • Notifies the receiver that a document was removed from the documents directory. If the URL does not contain the documents directory, then this method does nothing.

    Warning

    If the explicitModeEnabled property is set to NO, this method will assert and crash.

    Declaration

    Objective-C

    - (void)didRemoveDocumentAtURL:(nonnull NSURL *)URL;

    Swift

    func didRemoveDocument(at URL: URL)

    Parameters

    URL

    The URL for the document that was added or modified.