Class FileSystemSyncAccessHandle
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The FileSystemSyncAccessHandle interface of the {{domxref("File System API", "File System API", "", "nocode")}} represents a synchronous handle to a file system entry.
[Value("FileSystemSyncAccessHandle")]
public class FileSystemSyncAccessHandle
- Inheritance
-
FileSystemSyncAccessHandle
- Inherited Members
Remarks
This class is only accessible inside dedicated Web Workers (so that its methods do not block execution on the main thread) for files within the origin private file system, which is not visible to end-users.
As a result, its methods are not subject to the same security checks as methods running on files within the user-visible file system, and so are much more performant. This makes them suitable for significant, large-scale file updates such as SQLite database modifications.
The interface is accessed through the 'FileSystemFileHandle.CreateSyncAccessHandle' method.
NOTE
In earlier versions of the spec, Close(), Flush(), GetSize(), and Truncate(ulong) were wrongly specified as asynchronous methods, and older versions of some browsers implement them in this way. However, all current browsers that support these methods implement them as synchronous methods.
-File System API
-The File System Access API: simplifying access to local files
Constructors
FileSystemSyncAccessHandle()
public FileSystemSyncAccessHandle()
Methods
Close()
The close() method of the
FileSystemSyncAccessHandle interface closes an open synchronous file handle, disabling any further operations on it and releasing the exclusive lock previously put on the file associated with the file handle.
[Value("close")]
public GlobalObject.Undefined Close()
Returns
- GlobalObject.Undefined
None ('undefined').
Remarks
NOTE
In earlier versions of the spec,
close(), Flush(), GetSize(), and Truncate(ulong) were wrongly specified as asynchronous methods, and older versions of some browsers implement them in this way. However, all current browsers that support these methods implement them as synchronous methods.
-File System API
-The File System Access API: simplifying access to local files
Flush()
The flush() method of the
FileSystemSyncAccessHandle interface persists any changes made to the file associated with the handle via the 'FileSystemSyncAccessHandle.Write' method to disk.
[Value("flush")]
public GlobalObject.Undefined Flush()
Returns
- GlobalObject.Undefined
None ('undefined').
Remarks
Bear in mind that you only need to call this method if you need the changes committed to disk at a specific time, otherwise you can leave the underlying operating system to handle this when it sees fit, which should be OK in most cases.
NOTE
In earlier versions of the spec, Close(),
flush(), GetSize(), and Truncate(ulong) were wrongly specified as asynchronous methods, and older versions of some browsers implement them in this way. However, all current browsers that support these methods implement them as synchronous methods.
-File System API
-The File System Access API: simplifying access to local files
GetSize()
The getSize() method of the
FileSystemSyncAccessHandle interface returns the size of the file associated with the handle in bytes.
[Value("getSize")]
public ulong GetSize()
Returns
- ulong
A number representing the size of the file in bytes.
Remarks
NOTE
In earlier versions of the spec, Close(), Flush(),
getSize(), and Truncate(ulong) were wrongly specified as asynchronous methods, and older versions of some browsers implement them in this way. However, all current browsers that support these methods implement them as synchronous methods.
-File System API
-The File System Access API: simplifying access to local files
Read(Union225, FileSystemReadWriteOptions)
The read() method of the
FileSystemSyncAccessHandle interface reads the content of the file associated with the handle into a specified buffer, optionally at a given offset.
[Value("read")]
public ulong Read(Union225 buffer, FileSystemReadWriteOptions options = null)
Parameters
bufferUnion225optionsFileSystemReadWriteOptions
Returns
- ulong
A number representing the number of bytes read from the file.
Remarks
Truncate(ulong)
The truncate() method of the
FileSystemSyncAccessHandle interface resizes the file associated with the handle to a specified number of bytes.
[Value("truncate")]
public GlobalObject.Undefined Truncate(ulong newSize)
Parameters
newSizeulong
Returns
- GlobalObject.Undefined
None ('undefined').
Remarks
NOTE
In earlier versions of the spec, Close(), Flush(), GetSize(), and
truncate()were wrongly specified as asynchronous methods, and older versions of some browsers implement them in this way. However, all current browsers that support these methods implement them as synchronous methods.
-File System API
-The File System Access API: simplifying access to local files
Write(Union225, FileSystemReadWriteOptions)
The write() method of the
FileSystemSyncAccessHandle interface writes the content of a specified buffer to the file associated with the handle, optionally at a given offset.
[Value("write")]
public ulong Write(Union225 buffer, FileSystemReadWriteOptions options = null)
Parameters
bufferUnion225optionsFileSystemReadWriteOptions
Returns
- ulong
A number representing the number of bytes written to the file.
Remarks
Files within the origin private file system are not visible to end-users, therefore are not subject to the same security checks as methods running on files within the user-visible file system. As a result, writes performed using FileSystemSyncAccessHandle.write() are much more performant. This makes them suitable for significant, large-scale file updates such as SQLite database modifications.
-File System API
-The File System Access API: simplifying access to local files