PSPDFFileDataProvider

Objective-C


@interface PSPDFFileDataProvider : NSObject <PSPDFFileDataProviding>

Swift

class FileDataProvider : NSObject, FileDataProviding

An implementation of PSPDFDataProviding that acts upon a file.

  • 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 FileDataProvider with the given fileURL.

    When passing a progress object that returns false for its isFinished property, the newly initialized object is considered in-flight. The main implications of this state are:

    • the instance will assume that there is no file at fileURL, yet
    • therefore, the data property will be nil
    • as will the UID be
    • calling replace(with:) will fail with PSPDFKit.Error.dataProviderInFlight

    Note

    If you are expecting to encounter symlinks or alias files, you need to first resolve those using the apropriate URL APIs before passing them here. For performance reasons, FileDataProvider will not automatically resolve them for you.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithFileURL:(nonnull NSURL *)fileURL
                                   progress:(nullable NSProgress *)progress;

    Swift

    init(fileURL: URL, progress: Progress?)

    Parameters

    fileURL

    A resolved file URL pointing to a file on the filesystem.

    progress

    (Optional) A Progress instance that indicates progress until the file at fileURL can be accessed.

    Return Value

    A new file provider.

  • See

    initWithFileURL:progress:

    Declaration

    Objective-C

    - (nonnull instancetype)initWithFileURL:(nonnull NSURL *)fileURL;

    Swift

    convenience init(fileURL: URL)
  • The progress object passed during initialization — if any.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) NSProgress *progress;

    Swift

    var progress: Progress? { get }
  • Creates a new FileDataSink with the given options, pointed at a unique temporary file with the same path extension as the receiver’s fileURL.

    This method fails if the temporary file for the new data sink could not be created.

    Declaration

    Objective-C

    - (nullable id<PSPDFDataSink>)
        createDataSinkWithOptions:(PSPDFDataSinkOptions)options
                            error:(NSError *_Nullable *_Nullable)error;

    Swift

    func createDataSink(options: DataSinkOptions = []) throws -> DataSink
  • Replaces the file backing the receiver based on the data backing replacementDataSink.

    This method fails if the receiver is in-flight or if writing replacementDataSink’s data to fileURL fails.

    Warning

    This method raises an exception if replacementDataSink is not an instance of FileDataSink, or if replacementDataSink.isFinished is false.

    Declaration

    Objective-C

    - (BOOL)replaceContentsWithDataSink:
                (nonnull id<PSPDFDataSink>)replacementDataSink
                                  error:(NSError *_Nullable *_Nullable)error;

    Swift

    func replaceContents(with replacementDataSink: DataSink) throws

    Parameters

    replacementDataSink

    An instance of FileDataSink, typically created by calling createDataSink(options:).

    error

    A pointer to populate with an error IFF replacing the receiver’s content fails.

  • Whether or not a writable file exists at fileURL.

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL canWrite;

    Swift

    var canWrite: Bool { get }
  • Removes the file backing the receiver.

    This method fails if the receiver is in-flight, or when the item at fileURL cannot be deleted.

    Declaration

    Objective-C

    - (BOOL)deleteDataWithError:(NSError *_Nullable *_Nullable)error;

    Swift

    func deleteData() throws
  • Lets go of all resources held by the receiver.

    Will block until any ongoing read or write access through the receiver has finished.

    Declaration

    Objective-C

    - (void)clearCache;

    Swift

    func clearCache()