Trait dokan::FileSystemHandler[][src]

pub trait FileSystemHandler<'a, 'b: 'a>: Sync + Sized + 'b {
    type Context: Sync + 'a;
    fn create_file(
        &'b self,
        _file_name: &U16CStr,
        _security_context: &DOKAN_IO_SECURITY_CONTEXT,
        _desired_access: ACCESS_MASK,
        _file_attributes: u32,
        _share_access: u32,
        _create_disposition: u32,
        _create_options: u32,
        _info: &mut OperationInfo<'a, 'b, Self>
    ) -> Result<CreateFileInfo<Self::Context>, OperationError> { ... }
fn cleanup(
        &'b self,
        _file_name: &U16CStr,
        _info: &OperationInfo<'a, 'b, Self>,
        _context: &'a Self::Context
    ) { ... }
fn close_file(
        &'b self,
        _file_name: &U16CStr,
        _info: &OperationInfo<'a, 'b, Self>,
        _context: &'a Self::Context
    ) { ... }
fn read_file(
        &'b self,
        _file_name: &U16CStr,
        _offset: i64,
        _buffer: &mut [u8],
        _info: &OperationInfo<'a, 'b, Self>,
        _context: &'a Self::Context
    ) -> Result<u32, OperationError> { ... }
fn write_file(
        &'b self,
        _file_name: &U16CStr,
        _offset: i64,
        _buffer: &[u8],
        _info: &OperationInfo<'a, 'b, Self>,
        _context: &'a Self::Context
    ) -> Result<u32, OperationError> { ... }
fn flush_file_buffers(
        &'b self,
        _file_name: &U16CStr,
        _info: &OperationInfo<'a, 'b, Self>,
        _context: &'a Self::Context
    ) -> Result<(), OperationError> { ... }
fn get_file_information(
        &'b self,
        _file_name: &U16CStr,
        _info: &OperationInfo<'a, 'b, Self>,
        _context: &'a Self::Context
    ) -> Result<FileInfo, OperationError> { ... }
fn find_files(
        &'b self,
        _file_name: &U16CStr,
        _fill_find_data: impl FnMut(&FindData) -> Result<(), FillDataError>,
        _info: &OperationInfo<'a, 'b, Self>,
        _context: &'a Self::Context
    ) -> Result<(), OperationError> { ... }
fn find_files_with_pattern(
        &'b self,
        _file_name: &U16CStr,
        _pattern: &U16CStr,
        _fill_find_data: impl FnMut(&FindData) -> Result<(), FillDataError>,
        _info: &OperationInfo<'a, 'b, Self>,
        _context: &'a Self::Context
    ) -> Result<(), OperationError> { ... }
fn set_file_attributes(
        &'b self,
        _file_name: &U16CStr,
        _file_attributes: u32,
        _info: &OperationInfo<'a, 'b, Self>,
        _context: &'a Self::Context
    ) -> Result<(), OperationError> { ... }
fn set_file_time(
        &'b self,
        _file_name: &U16CStr,
        _creation_time: FileTimeInfo,
        _last_access_time: FileTimeInfo,
        _last_write_time: FileTimeInfo,
        _info: &OperationInfo<'a, 'b, Self>,
        _context: &'a Self::Context
    ) -> Result<(), OperationError> { ... }
fn delete_file(
        &'b self,
        _file_name: &U16CStr,
        _info: &OperationInfo<'a, 'b, Self>,
        _context: &'a Self::Context
    ) -> Result<(), OperationError> { ... }
fn delete_directory(
        &'b self,
        _file_name: &U16CStr,
        _info: &OperationInfo<'a, 'b, Self>,
        _context: &'a Self::Context
    ) -> Result<(), OperationError> { ... }
fn move_file(
        &'b self,
        _file_name: &U16CStr,
        _new_file_name: &U16CStr,
        _replace_if_existing: bool,
        _info: &OperationInfo<'a, 'b, Self>,
        _context: &'a Self::Context
    ) -> Result<(), OperationError> { ... }
fn set_end_of_file(
        &'b self,
        _file_name: &U16CStr,
        _offset: i64,
        _info: &OperationInfo<'a, 'b, Self>,
        _context: &'a Self::Context
    ) -> Result<(), OperationError> { ... }
fn set_allocation_size(
        &'b self,
        _file_name: &U16CStr,
        _alloc_size: i64,
        _info: &OperationInfo<'a, 'b, Self>,
        _context: &'a Self::Context
    ) -> Result<(), OperationError> { ... }
fn lock_file(
        &'b self,
        _file_name: &U16CStr,
        _offset: i64,
        _length: i64,
        _info: &OperationInfo<'a, 'b, Self>,
        _context: &'a Self::Context
    ) -> Result<(), OperationError> { ... }
fn unlock_file(
        &'b self,
        _file_name: &U16CStr,
        _offset: i64,
        _length: i64,
        _info: &OperationInfo<'a, 'b, Self>,
        _context: &'a Self::Context
    ) -> Result<(), OperationError> { ... }
fn get_disk_free_space(
        &'b self,
        _info: &OperationInfo<'a, 'b, Self>
    ) -> Result<DiskSpaceInfo, OperationError> { ... }
fn get_volume_information(
        &'b self,
        _info: &OperationInfo<'a, 'b, Self>
    ) -> Result<VolumeInfo, OperationError> { ... }
fn mounted(
        &'b self,
        _info: &OperationInfo<'a, 'b, Self>
    ) -> Result<(), OperationError> { ... }
fn unmounted(
        &'b self,
        _info: &OperationInfo<'a, 'b, Self>
    ) -> Result<(), OperationError> { ... }
fn get_file_security(
        &'b self,
        _file_name: &U16CStr,
        _security_information: u32,
        _security_descriptor: PSECURITY_DESCRIPTOR,
        _buffer_length: u32,
        _info: &OperationInfo<'a, 'b, Self>,
        _context: &'a Self::Context
    ) -> Result<u32, OperationError> { ... }
fn set_file_security(
        &'b self,
        _file_name: &U16CStr,
        _security_information: u32,
        _security_descriptor: PSECURITY_DESCRIPTOR,
        _buffer_length: u32,
        _info: &OperationInfo<'a, 'b, Self>,
        _context: &'a Self::Context
    ) -> Result<(), OperationError> { ... }
fn find_streams(
        &'b self,
        _file_name: &U16CStr,
        _fill_find_stream_data: impl FnMut(&FindStreamData) -> Result<(), FillDataError>,
        _info: &OperationInfo<'a, 'b, Self>,
        _context: &'a Self::Context
    ) -> Result<(), OperationError> { ... } }

Types that implements this trait can handle file system operations for a mounted volume.

Dokan invokes the callback functions in this trait to handle file system operations. These functions has similar semantics to that of corresponding Windows API functions.

Implementation of most callback functions can be omitted by returning STATUS_NOT_IMPLEMENTED if the corresponding feature is not supported. To make things flexible, all of the functions are provided with a default implementation which is a no-op and returns STATUS_NOT_IMPLEMENTED (except cleanup and close_file which don’t have return values). However, omitting the implementation of some important callbacks such as create_file will make the file system unusable.

Associated Types

type Context: Sync + 'a[src]

Type of the context associated with an open file object.

Loading content...

Provided methods

fn create_file(
    &'b self,
    _file_name: &U16CStr,
    _security_context: &DOKAN_IO_SECURITY_CONTEXT,
    _desired_access: ACCESS_MASK,
    _file_attributes: u32,
    _share_access: u32,
    _create_disposition: u32,
    _create_options: u32,
    _info: &mut OperationInfo<'a, 'b, Self>
) -> Result<CreateFileInfo<Self::Context>, OperationError>
[src]

Called when a file object is created.

The flags passed to this function has similar meaning to that of ZwCreateFile. You can convert them to flags accepted by CreateFile using the map_kernel_to_user_create_file_flags helper function.

fn cleanup(
    &'b self,
    _file_name: &U16CStr,
    _info: &OperationInfo<'a, 'b, Self>,
    _context: &'a Self::Context
)
[src]

Called when the last handle for the file object has been closed.

If info.delete_on_close returns true, the file should be deleted in this function. As the function doesn’t have a return value, you should make sure the file is deletable in delete_file or delete_directory.

Note that the file object hasn’t been released and there might be more I/O operations before close_file gets called. (This typically happens when the file is memory-mapped.)

Normally close_file will be called shortly after this function. However, the file object may also be reused, and in that case create_file will be called instead.

fn close_file(
    &'b self,
    _file_name: &U16CStr,
    _info: &OperationInfo<'a, 'b, Self>,
    _context: &'a Self::Context
)
[src]

Called when the last handle for the handle object has been closed and released.

This is the last function called during the lifetime of the file object. You can safely release any resources allocated for it (such as file handles, buffers, etc.). The associated context object will also be dropped once this function returns. In case the file object is reused and thus this function isn’t called, the context will be dropped before create_file gets called.

fn read_file(
    &'b self,
    _file_name: &U16CStr,
    _offset: i64,
    _buffer: &mut [u8],
    _info: &OperationInfo<'a, 'b, Self>,
    _context: &'a Self::Context
) -> Result<u32, OperationError>
[src]

Reads data from the file.

The number of bytes that actually gets read should be returned.

See ReadFile for more information.

fn write_file(
    &'b self,
    _file_name: &U16CStr,
    _offset: i64,
    _buffer: &[u8],
    _info: &OperationInfo<'a, 'b, Self>,
    _context: &'a Self::Context
) -> Result<u32, OperationError>
[src]

Writes data to the file.

The number of bytes that actually gets written should be returned.

If info.write_to_eof returns true, data should be written to the end of file and the offset parameter should be ignored.

See WriteFile for more information.

fn flush_file_buffers(
    &'b self,
    _file_name: &U16CStr,
    _info: &OperationInfo<'a, 'b, Self>,
    _context: &'a Self::Context
) -> Result<(), OperationError>
[src]

Flushes the buffer of the file and causes all buffered data to be written to the file.

See FlushFileBuffers for more information.

fn get_file_information(
    &'b self,
    _file_name: &U16CStr,
    _info: &OperationInfo<'a, 'b, Self>,
    _context: &'a Self::Context
) -> Result<FileInfo, OperationError>
[src]

Gets information about the file.

See GetFileInformationByHandle for more information.

fn find_files(
    &'b self,
    _file_name: &U16CStr,
    _fill_find_data: impl FnMut(&FindData) -> Result<(), FillDataError>,
    _info: &OperationInfo<'a, 'b, Self>,
    _context: &'a Self::Context
) -> Result<(), OperationError>
[src]

Lists all child items in the directory.

fill_find_data should be called for every child item in the directory.

It will only be called if find_files_with_pattern returns STATUS_NOT_IMPLEMENTED.

See FindFirstFile for more information.

fn find_files_with_pattern(
    &'b self,
    _file_name: &U16CStr,
    _pattern: &U16CStr,
    _fill_find_data: impl FnMut(&FindData) -> Result<(), FillDataError>,
    _info: &OperationInfo<'a, 'b, Self>,
    _context: &'a Self::Context
) -> Result<(), OperationError>
[src]

Lists all child items that matches the specified pattern in the directory.

fill_find_data should be called for every matching child item in the directory.

is_name_in_expression can be used to determine if a file name matches the pattern.

If this function returns STATUS_NOT_IMPLEMENTED, find_files will be called instead and pattern matching will be handled directly by Dokan.

See FindFirstFile for more information.

fn set_file_attributes(
    &'b self,
    _file_name: &U16CStr,
    _file_attributes: u32,
    _info: &OperationInfo<'a, 'b, Self>,
    _context: &'a Self::Context
) -> Result<(), OperationError>
[src]

Sets attributes of the file.

file_attributes can be combination of one or more file attribute constants defined by Windows.

See SetFileAttributes for more information.

fn set_file_time(
    &'b self,
    _file_name: &U16CStr,
    _creation_time: FileTimeInfo,
    _last_access_time: FileTimeInfo,
    _last_write_time: FileTimeInfo,
    _info: &OperationInfo<'a, 'b, Self>,
    _context: &'a Self::Context
) -> Result<(), OperationError>
[src]

Sets the time when the file was created, last accessed and last written.

See SetFileTime for more information.

fn delete_file(
    &'b self,
    _file_name: &U16CStr,
    _info: &OperationInfo<'a, 'b, Self>,
    _context: &'a Self::Context
) -> Result<(), OperationError>
[src]

Checks if the file can be deleted.

The file should not be deleted in this function. Instead, it should only check if the file can be deleted and return Ok if that is possible.

It will also be called with info.delete_on_close returning false to notify that the file is no longer requested to be deleted.

fn delete_directory(
    &'b self,
    _file_name: &U16CStr,
    _info: &OperationInfo<'a, 'b, Self>,
    _context: &'a Self::Context
) -> Result<(), OperationError>
[src]

Checks if the directory can be deleted.

Similar to delete_file, it should only check if the directory can be deleted and delay the actual deletion to the cleanup function.

It will also be called with info.delete_on_close returning false to notify that the directory is no longer requested to be deleted.

fn move_file(
    &'b self,
    _file_name: &U16CStr,
    _new_file_name: &U16CStr,
    _replace_if_existing: bool,
    _info: &OperationInfo<'a, 'b, Self>,
    _context: &'a Self::Context
) -> Result<(), OperationError>
[src]

Moves the file.

If the new_file_name already exists, the function should only replace the existing file when replace_if_existing is true, otherwise it should return appropriate error.

Note that renaming is a special kind of moving and is also handled by this function.

See MoveFileEx for more information.

fn set_end_of_file(
    &'b self,
    _file_name: &U16CStr,
    _offset: i64,
    _info: &OperationInfo<'a, 'b, Self>,
    _context: &'a Self::Context
) -> Result<(), OperationError>
[src]

Sets end-of-file position of the file.

The offset value is zero-based, so it actually refers to the offset to the byte immediately following the last valid byte in the file.

See FILE_END_OF_FILE_INFORMATION for more information.

fn set_allocation_size(
    &'b self,
    _file_name: &U16CStr,
    _alloc_size: i64,
    _info: &OperationInfo<'a, 'b, Self>,
    _context: &'a Self::Context
) -> Result<(), OperationError>
[src]

Sets allocation size of the file.

The allocation size is the number of bytes allocated in the underlying physical device for the file.

See FILE_ALLOCATION_INFORMATION for more information.

fn lock_file(
    &'b self,
    _file_name: &U16CStr,
    _offset: i64,
    _length: i64,
    _info: &OperationInfo<'a, 'b, Self>,
    _context: &'a Self::Context
) -> Result<(), OperationError>
[src]

Locks the file for exclusive access.

It will only be called if MountFlags::FILELOCK_USER_MODE was specified when mounting the volume, otherwise Dokan will take care of file locking.

See LockFile for more information.

fn unlock_file(
    &'b self,
    _file_name: &U16CStr,
    _offset: i64,
    _length: i64,
    _info: &OperationInfo<'a, 'b, Self>,
    _context: &'a Self::Context
) -> Result<(), OperationError>
[src]

Unlocks the previously locked file.

It will only be called if MountFlags::FILELOCK_USER_MODE was specified when mounting the volume, otherwise Dokan will take care of file locking.

See UnlockFile for more information.

fn get_disk_free_space(
    &'b self,
    _info: &OperationInfo<'a, 'b, Self>
) -> Result<DiskSpaceInfo, OperationError>
[src]

Gets free space information about the disk.

See GetDiskFreeSpaceEx for more information.

fn get_volume_information(
    &'b self,
    _info: &OperationInfo<'a, 'b, Self>
) -> Result<VolumeInfo, OperationError>
[src]

Gets information about the volume and file system.

See GetVolumeInformation for more information.

fn mounted(
    &'b self,
    _info: &OperationInfo<'a, 'b, Self>
) -> Result<(), OperationError>
[src]

Called when Dokan has successfully mounted the volume.

fn unmounted(
    &'b self,
    _info: &OperationInfo<'a, 'b, Self>
) -> Result<(), OperationError>
[src]

Called when Dokan is unmounting the volume.

fn get_file_security(
    &'b self,
    _file_name: &U16CStr,
    _security_information: u32,
    _security_descriptor: PSECURITY_DESCRIPTOR,
    _buffer_length: u32,
    _info: &OperationInfo<'a, 'b, Self>,
    _context: &'a Self::Context
) -> Result<u32, OperationError>
[src]

Gets security information of a file.

Size of the security descriptor in bytes should be returned on success. If the buffer is not large enough, the number should still be returned, and STATUS_BUFFER_OVERFLOW will be automatically passed to Dokan if it is larger than buffer_length.

See GetFileSecurity for more information.

fn set_file_security(
    &'b self,
    _file_name: &U16CStr,
    _security_information: u32,
    _security_descriptor: PSECURITY_DESCRIPTOR,
    _buffer_length: u32,
    _info: &OperationInfo<'a, 'b, Self>,
    _context: &'a Self::Context
) -> Result<(), OperationError>
[src]

Sets security information of a file.

See SetFileSecurity for more information.

fn find_streams(
    &'b self,
    _file_name: &U16CStr,
    _fill_find_stream_data: impl FnMut(&FindStreamData) -> Result<(), FillDataError>,
    _info: &OperationInfo<'a, 'b, Self>,
    _context: &'a Self::Context
) -> Result<(), OperationError>
[src]

Lists all alternative streams of the file.

fill_find_stream_data should be called for every stream of the file, including the default data stream ::$DATA.

See FindFirstStream for more information.

Loading content...

Implementors

Loading content...