Interface FileWriterSync

This interface lets users write, truncate, and append to files using simple synchronous calls. This interface is specified to be used only within Web Workers (WorkerUtils [WEBWORKERS]).

Index

Properties

Methods

Properties

public length: number

The length of the file. If the user does not have read access to the file, this must be the highest byte offset at which the user has written.

public position: number

The byte offset at which the next write to the file will occur. This must be no greater than length.

Methods

public seek(offset: number)

Seek sets the file position at which the next write will occur.

Parameters

  • offset: number

    An absolute byte offset into the file. If offset is greater than length, length is used instead. If offset is less than zero, length is added to it, so that it is treated as an offset back from the end of the file. If it is still less than zero, zero is used.

public truncate(size: number)

Changes the length of the file to that specified. If shortening the file, data beyond the new length must be discarded. If extending the file, the existing data must be zero-padded up to the new length. Upon successful completion:

  • length must be equal to size.
  • position must be the lesser of
    • its pre-truncate value,
    • size.

Parameters

  • size: number

    The size to which the length of the file is to be adjusted, measured in bytes.

public write(data: Blob)

Write the supplied data to the file at position. Upon completion, position will increase by data.size.

Parameters

  • data: Blob

    The blob to write.