PSPDFLibraryFileSystemDataSource

Objective-C


@interface PSPDFLibraryFileSystemDataSource : NSObject <PSPDFLibraryDataSource>

Swift

class LibraryFileSystemDataSource : NSObject, LibraryDataSource

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

  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    PSPDF_EMPTY_INIT_UNAVAILABLE
  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    PSPDF_EMPTY_INIT_UNAVAILABLE
  • 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: PDFLibrary, 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 (nonatomic, weak, readonly) PSPDFLibrary *_Nullable library;

    Swift

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

    Declaration

    Objective-C

    @property (nonatomic, readonly) 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 (copy, 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 NSDirectoryEnumerationOptions directoryEnumerationOptions;

    Swift

    var directoryEnumerationOptions: FileManager.DirectoryEnumerationOptions { get set }
  • Defaults to just contain only pdf. Set to nil or an empty set to allow all files. Any changes will take effect only if made prior to starting indexing using PSPDFLibrary.

    Declaration

    Objective-C

    @property (nullable) NSSet<NSString *> *allowedPathExtensions;

    Swift

    var allowedPathExtensions: Set<String>? { 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 specified UID, else nil.

  • The document provider to be set to customize the documents to be used by the file system data source. One possible use is to unlock or decrypt documents. Called when a document is requested by the PSPDFLibrary.

    Declaration

    Objective-C

    @property (weak) id< PSPDFLibraryFileSystemDataSourceDocumentProvider> _Nullable documentProvider;

    Swift

    weak var documentProvider: LibraryFileSystemDataSourceDocumentProvider? { 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 (atomic, assign, unsafe_unretained, readwrite,
              getter=isExplicitModeEnabled) 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 false, 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 false, 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.