All Known Implementing Classes:
ReadWriteAdapter

public interface DokanyFileSystem
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    cleanup(com.sun.jna.WString rawPath, DokanyFileInfo dokanyFileInfo)
    Receipt of this request indicates that the last handle for a file object that is associated with the target device object has been closed (but, due to outstanding I/O requests, might not have been released).
    void
    closeFile(com.sun.jna.WString rawPath, DokanyFileInfo dokanyFileInfo)
    CloseFile is called at the end of the life of the context.
    int
    deleteDirectory(com.sun.jna.WString rawPath, DokanyFileInfo dokanyFileInfo)
    Check if it is possible to delete a directory.
    int
    deleteFile(com.sun.jna.WString rawPath, DokanyFileInfo dokanyFileInfo)
    Check if it is possible to delete a file.
    void
    fillWin32FindData(com.sun.jna.platform.win32.WinBase.WIN32_FIND_DATA rawFillFindData, DokanyFileInfo dokanyFileInfo)
     
    int
    findFiles(com.sun.jna.WString rawPath, DokanyOperations.FillWin32FindData rawFillFindData, DokanyFileInfo dokanyFileInfo)
    List all files in the path requested.
    int
    findFilesWithPattern(com.sun.jna.WString fileName, com.sun.jna.WString searchPattern, DokanyOperations.FillWin32FindData rawFillFindData, DokanyFileInfo dokanyFileInfo)
    Same as findFiles(WString, DokanyOperations.FillWin32FindData, DokanyFileInfo) but with a search pattern to filter the result.
    int
    findStreams(com.sun.jna.WString rawPath, DokanyOperations.FillWin32FindStreamData rawFillFindData, DokanyFileInfo dokanyFileInfo)
    Retrieve all NTFS Streams informations on the file.
    int
    flushFileBuffers(com.sun.jna.WString rawPath, DokanyFileInfo dokanyFileInfo)
    Clears buffers for this context and causes any buffered data to be written to the file.
    int
    getDiskFreeSpace(com.sun.jna.ptr.LongByReference freeBytesAvailable, com.sun.jna.ptr.LongByReference totalNumberOfBytes, com.sun.jna.ptr.LongByReference totalNumberOfFreeBytes, DokanyFileInfo dokanyFileInfo)
    Retrieves information about the amount of space that is available on a disk volume, which is the total amount of space, the total amount of free space, and the total amount of free space available to the user that is associated with the calling thread.
    int
    getFileInformation(com.sun.jna.WString fileName, ByHandleFileInfo handleFileInfo, DokanyFileInfo dokanyFileInfo)
    Get specific informations on a file.
    int
    getFileSecurity(com.sun.jna.WString rawPath, int rawSecurityInformation, com.sun.jna.Pointer rawSecurityDescriptor, int rawSecurityDescriptorLength, com.sun.jna.ptr.IntByReference rawSecurityDescriptorLengthNeeded, DokanyFileInfo dokanyFileInfo)
    Get specified information about the security of a file or directory.
    int
    getVolumeInformation(com.sun.jna.Pointer rawVolumeNameBuffer, int rawVolumeNameSize, com.sun.jna.ptr.IntByReference rawVolumeSerialNumber, com.sun.jna.ptr.IntByReference rawMaximumComponentLength, com.sun.jna.ptr.IntByReference rawFileSystemFlags, com.sun.jna.Pointer rawFileSystemNameBuffer, int rawFileSystemNameSize, DokanyFileInfo dokanyFileInfo)
    Retrieves information about the file system and volume associated with the specified root directory.
    int
    lockFile(com.sun.jna.WString rawPath, long rawByteOffset, long rawLength, DokanyFileInfo dokanyFileInfo)
    Lock file at a specific offset and data length.
    int
    mounted(DokanyFileInfo dokanyFileInfo)
    Is called when Dokany succeeded mounting the volume.
    int
    moveFile(com.sun.jna.WString rawPath, com.sun.jna.WString rawNewFileName, boolean rawReplaceIfExisting, DokanyFileInfo dokanyFileInfo)
    Move a file or directory to a new location.
    int
    readFile(com.sun.jna.WString rawPath, com.sun.jna.Pointer rawBuffer, int rawBufferLength, com.sun.jna.ptr.IntByReference rawReadLength, long rawOffset, DokanyFileInfo dokanyFileInfo)
    int
    setAllocationSize(com.sun.jna.WString rawPath, long rawLength, DokanyFileInfo dokanyFileInfo)
    SetAllocationSize is used to truncate or extend a file.
    int
    setEndOfFile(com.sun.jna.WString rawPath, long rawByteOffset, DokanyFileInfo dokanyFileInfo)
    SetEndOfFile is used to truncate or extend a file (physical file size).
    int
    setFileAttributes(com.sun.jna.WString rawPath, int rawAttributes, DokanyFileInfo dokanyFileInfo)
    Set file attributes on a specific file.
    int
    setFileSecurity(com.sun.jna.WString rawPath, int rawSecurityInformation, com.sun.jna.Pointer rawSecurityDescriptor, int rawSecurityDescriptorLength, DokanyFileInfo dokanyFileInfo)
    Sets the security of a file or directory object.
    int
    setFileTime(com.sun.jna.WString rawPath, com.sun.jna.platform.win32.WinBase.FILETIME rawCreationTime, com.sun.jna.platform.win32.WinBase.FILETIME rawLastAccessTime, com.sun.jna.platform.win32.WinBase.FILETIME rawLastWriteTime, DokanyFileInfo dokanyFileInfo)
    Set file times on a specific file.
    int
    unlockFile(com.sun.jna.WString rawPath, long rawByteOffset, long rawLength, DokanyFileInfo dokanyFileInfo)
    Unlock file at a specific offset and data length.
    int
    unmounted(DokanyFileInfo dokanyFileInfo)
    Is called when Dokany succeeded unmounting the volume.
    int
    writeFile(com.sun.jna.WString rawPath, com.sun.jna.Pointer rawBuffer, int rawNumberOfBytesToWrite, com.sun.jna.ptr.IntByReference rawNumberOfBytesWritten, long rawOffset, DokanyFileInfo dokanyFileInfo)
    WriteFile callback on the file previously opened in zwCreateFile(WString, WinBase.SECURITY_ATTRIBUTES, int, int, int, int, int, DokanyFileInfo) It can be called by different thread at the same time, therefore the write/context has to be thread safe.
    int
    zwCreateFile(com.sun.jna.WString rawPath, com.sun.jna.platform.win32.WinBase.SECURITY_ATTRIBUTES securityContext, int rawDesiredAccess, int rawFileAttributes, int rawShareAccess, int rawCreateDisposition, int rawCreateOptions, DokanyFileInfo dokanyFileInfo)
    CreateFile Dokan API callback.
  • Method Details

    • zwCreateFile

      int zwCreateFile(com.sun.jna.WString rawPath, com.sun.jna.platform.win32.WinBase.SECURITY_ATTRIBUTES securityContext, int rawDesiredAccess, int rawFileAttributes, int rawShareAccess, int rawCreateDisposition, int rawCreateOptions, DokanyFileInfo dokanyFileInfo)
      CreateFile Dokan API callback. CreateFile is called each time a request is made on a file system object. In case OPEN_ALWAYS & CREATE_ALWAYS are successfully opening an existing file, STATUS_OBJECT_NAME_COLLISION should be returned instead of STATUS_SUCCESS . This will inform Dokan that the file has been opened and not created during the request. If the file is a directory, CreateFile is also called. In this case, CreateFile should return NtStatus.SUCCESS when that directory can be opened and DokanyFileInfo.IsDirectory has to be set to TRUE. On the other hand, if DokanyFileInfo.IsDirectory is set to TRUE but the path targets a file, NtStatus.NOT_A_DIRECTORY must be returned. DokanyFileInfo.Context can be used to store Data (like a filehandle) that can be retrieved in all other requests related to the Context. To avoid memory leak, Context needs to be released in cleanup(WString, DokanyFileInfo) .
      Parameters:
      rawPath - Path requested by the Kernel on the File System. TODO: rewrite this parameter description to link to winBase
      securityContext - the security context of the kernel (see also in the windows driver API IO_SECURITY_CONTEXT)
      rawDesiredAccess - Permissions for file or directory. (see also in the windows API ACCESS_MASK
      rawFileAttributes - Provides attributes for files and directories. (see also in the .NET API System.IO.FileAttributes}
      rawShareAccess - Type of share access to other threads. Device and intermediate drivers usually set ShareAccess to zero, which gives the caller exclusive access to the open file.
      rawCreateDisposition - Specifies the action to perform if the file does or does not exist. Can be translated into a readable thing via CreationDisposition
      rawCreateOptions - Specifies the options to apply when the driver creates or opens the file. (see also in the .NET API System.IO.FileOptions)
      dokanyFileInfo - DokanyFileInfo with information about the file or directory.
      Returns:
      integer code of a NtStatus
      See Also:
    • cleanup

      void cleanup(com.sun.jna.WString rawPath, DokanyFileInfo dokanyFileInfo)
      Receipt of this request indicates that the last handle for a file object that is associated with the target device object has been closed (but, due to outstanding I/O requests, might not have been released).

      Cleanup is requested before @{link closeFile(WString, DokanyFileInfo) is called.

      Parameters:
      rawPath -
      dokanyFileInfo - DokanyFileInfo with information about the file or directory.
    • closeFile

      void closeFile(com.sun.jna.WString rawPath, DokanyFileInfo dokanyFileInfo)
      CloseFile is called at the end of the life of the context. Receipt of this request indicates that the last handle of the file object that is associated with the target device object has been closed and released. All outstanding I/O requests have been completed or canceled.

      CloseFile is requested after cleanup(WString, DokanyFileInfo) is called. Anything remaining in DokanyFileInfo.Context has to be cleared before return.

      Parameters:
      rawPath -
      dokanyFileInfo - DokanyFileInfo with information about the file or directory.
    • readFile

      int readFile(com.sun.jna.WString rawPath, com.sun.jna.Pointer rawBuffer, int rawBufferLength, com.sun.jna.ptr.IntByReference rawReadLength, long rawOffset, DokanyFileInfo dokanyFileInfo)
      ReadFile callback on the file previously opened in zwCreateFile(WString, WinBase.SECURITY_ATTRIBUTES, int, int, int, int, int, DokanyFileInfo). It can be called by different thread at the same time, therefore the read has to be thread safe.
      Parameters:
      rawPath -
      rawBuffer -
      rawBufferLength -
      rawReadLength -
      rawOffset -
      dokanyFileInfo - DokanyFileInfo with information about the file or directory.
      Returns:
      NtStatus
    • writeFile

      int writeFile(com.sun.jna.WString rawPath, com.sun.jna.Pointer rawBuffer, int rawNumberOfBytesToWrite, com.sun.jna.ptr.IntByReference rawNumberOfBytesWritten, long rawOffset, DokanyFileInfo dokanyFileInfo)
      WriteFile callback on the file previously opened in zwCreateFile(WString, WinBase.SECURITY_ATTRIBUTES, int, int, int, int, int, DokanyFileInfo) It can be called by different thread at the same time, therefore the write/context has to be thread safe.
      Parameters:
      rawPath -
      rawBuffer -
      rawNumberOfBytesToWrite -
      rawNumberOfBytesWritten -
      rawOffset -
      dokanyFileInfo - DokanyFileInfo with information about the file or directory.
      Returns:
      NtStatus
    • flushFileBuffers

      int flushFileBuffers(com.sun.jna.WString rawPath, DokanyFileInfo dokanyFileInfo)
      Clears buffers for this context and causes any buffered data to be written to the file.
      Parameters:
      rawPath -
      dokanyFileInfo - DokanyFileInfo with information about the file or directory.
      Returns:
      NtStatus
    • getFileInformation

      int getFileInformation(com.sun.jna.WString fileName, ByHandleFileInfo handleFileInfo, DokanyFileInfo dokanyFileInfo)
      Get specific informations on a file.
      Parameters:
      fileName -
      handleFileInfo -
      dokanyFileInfo - DokanyFileInfo with information about the file or directory.
      Returns:
      NtStatus
    • findFiles

      int findFiles(com.sun.jna.WString rawPath, DokanyOperations.FillWin32FindData rawFillFindData, DokanyFileInfo dokanyFileInfo)
      List all files in the path requested.
      Parameters:
      rawPath -
      rawFillFindData -
      dokanyFileInfo - DokanyFileInfo with information about the file or directory.
      Returns:
      NtStatus
    • findFilesWithPattern

      int findFilesWithPattern(com.sun.jna.WString fileName, com.sun.jna.WString searchPattern, DokanyOperations.FillWin32FindData rawFillFindData, DokanyFileInfo dokanyFileInfo)
      Same as findFiles(WString, DokanyOperations.FillWin32FindData, DokanyFileInfo) but with a search pattern to filter the result.
      Parameters:
      fileName -
      searchPattern -
      rawFillFindData -
      dokanyFileInfo - DokanyFileInfo with information about the file or directory.
      Returns:
      NtStatus
    • setFileAttributes

      int setFileAttributes(com.sun.jna.WString rawPath, int rawAttributes, DokanyFileInfo dokanyFileInfo)
      Set file attributes on a specific file.
      Parameters:
      rawPath -
      rawAttributes -
      dokanyFileInfo - DokanyFileInfo with information about the file or directory.
      Returns:
      NtStatus
    • setFileTime

      int setFileTime(com.sun.jna.WString rawPath, com.sun.jna.platform.win32.WinBase.FILETIME rawCreationTime, com.sun.jna.platform.win32.WinBase.FILETIME rawLastAccessTime, com.sun.jna.platform.win32.WinBase.FILETIME rawLastWriteTime, DokanyFileInfo dokanyFileInfo)
      Set file times on a specific file.
      Parameters:
      rawPath - path to file or directory
      rawCreationTime - time of creation
      rawLastAccessTime - time of last access
      rawLastWriteTime - time of last modification
      dokanyFileInfo - DokanyFileInfo with information about the file or directory.
      Returns:
      NtStatus
    • deleteFile

      int deleteFile(com.sun.jna.WString rawPath, DokanyFileInfo dokanyFileInfo)
      Check if it is possible to delete a file.

      You should NOT delete the file in this method, but instead you must only check whether you can delete the file or not, and return NtStatus.SUCCESS (when you can delete it) or appropriate error codes such as NtStatus.ACCESS_DENIED, NtStatus.OBJECT_NO_LONGER_EXISTS, NtStatus.OBJECT_NAME_NOT_FOUND.

      deleteFile(WString, DokanyFileInfo) will also be called with DokanyFileInfo.DeleteOnClose set to false to notify the driver when the file is no longer requested to be deleted.

      When you return NtStatus.SUCCESS, you get a cleanup(WString, DokanyFileInfo) call afterwards with DokanyFileInfo.DeleteOnClose set to true and only then you have to actually delete the file being closed.

      Parameters:
      rawPath -
      dokanyFileInfo - DokanyFileInfo with information about the file.
      Returns:
      NtStatus
      See Also:
    • deleteDirectory

      int deleteDirectory(com.sun.jna.WString rawPath, DokanyFileInfo dokanyFileInfo)
      Check if it is possible to delete a directory.
      Parameters:
      rawPath -
      dokanyFileInfo - DokanyFileInfo with information about the directory.
      Returns:
      NtStatus
      See Also:
    • moveFile

      int moveFile(com.sun.jna.WString rawPath, com.sun.jna.WString rawNewFileName, boolean rawReplaceIfExisting, DokanyFileInfo dokanyFileInfo)
      Move a file or directory to a new location.
      Parameters:
      rawPath -
      rawNewFileName -
      rawReplaceIfExisting -
      dokanyFileInfo - DokanyFileInfo with information about the file or directory.
      Returns:
      NtStatus
    • setEndOfFile

      int setEndOfFile(com.sun.jna.WString rawPath, long rawByteOffset, DokanyFileInfo dokanyFileInfo)
      SetEndOfFile is used to truncate or extend a file (physical file size).
      Parameters:
      rawPath -
      rawByteOffset -
      dokanyFileInfo - DokanyFileInfo with information about the file or directory.
      Returns:
      NtStatus
    • setAllocationSize

      int setAllocationSize(com.sun.jna.WString rawPath, long rawLength, DokanyFileInfo dokanyFileInfo)
      SetAllocationSize is used to truncate or extend a file.
      Parameters:
      rawPath -
      rawLength -
      dokanyFileInfo - DokanyFileInfo with information about the file or directory.
      Returns:
      NtStatus
    • lockFile

      int lockFile(com.sun.jna.WString rawPath, long rawByteOffset, long rawLength, DokanyFileInfo dokanyFileInfo)
      Lock file at a specific offset and data length. This is only used if DokanOption.FILELOCK_USER_MODE is enabled.
      Parameters:
      rawPath -
      rawByteOffset -
      rawLength -
      dokanyFileInfo - DokanyFileInfo with information about the file or directory.
      Returns:
      NtStatus
    • unlockFile

      int unlockFile(com.sun.jna.WString rawPath, long rawByteOffset, long rawLength, DokanyFileInfo dokanyFileInfo)
      Unlock file at a specific offset and data length. This is only used if DokanOption.FILELOCK_USER_MODE is enabled.
      Parameters:
      rawPath -
      rawByteOffset -
      rawLength -
      dokanyFileInfo - DokanyFileInfo with information about the file or directory.
      Returns:
      NtStatus
    • getDiskFreeSpace

      int getDiskFreeSpace(com.sun.jna.ptr.LongByReference freeBytesAvailable, com.sun.jna.ptr.LongByReference totalNumberOfBytes, com.sun.jna.ptr.LongByReference totalNumberOfFreeBytes, DokanyFileInfo dokanyFileInfo)
      Retrieves information about the amount of space that is available on a disk volume, which is the total amount of space, the total amount of free space, and the total amount of free space available to the user that is associated with the calling thread.

      Neither this method nor getVolumeInformation(Pointer, int, IntByReference, IntByReference, IntByReference, Pointer, int, DokanyFileInfo) save the DokanyFileInfo.Context. Before these methods are called, zwCreateFile(WString, WinBase.SECURITY_ATTRIBUTES, int, int, int, int, int, DokanyFileInfo) may not be called. (ditto @{link DokanyOperations.CloseFile} and @{link DokanyOperations.Cleanup}).

      Parameters:
      freeBytesAvailable -
      totalNumberOfBytes -
      totalNumberOfFreeBytes -
      dokanyFileInfo - DokanyFileInfo with information about the file or directory.
      Returns:
      NtStatus
    • getVolumeInformation

      int getVolumeInformation(com.sun.jna.Pointer rawVolumeNameBuffer, int rawVolumeNameSize, com.sun.jna.ptr.IntByReference rawVolumeSerialNumber, com.sun.jna.ptr.IntByReference rawMaximumComponentLength, com.sun.jna.ptr.IntByReference rawFileSystemFlags, com.sun.jna.Pointer rawFileSystemNameBuffer, int rawFileSystemNameSize, DokanyFileInfo dokanyFileInfo)
      Retrieves information about the file system and volume associated with the specified root directory.

      Neither this method nor getVolumeInformation(Pointer, int, IntByReference, IntByReference, IntByReference, Pointer, int, DokanyFileInfo) save the DokanyFileInfo.Context. Before these methods are called, zwCreateFile(WString, WinBase.SECURITY_ATTRIBUTES, int, int, int, int, int, DokanyFileInfo) may not be called. (ditto @{link DokanyOperations.CloseFile} and @{link DokanyOperations.Cleanup}). FileSystemFeature.READ_ONLY_VOLUME is automatically added to the features if DokanOption.WRITE_PROTECTION was specified during mount.

      If NtStatus.NOT_IMPLEMENTED is returned, the Dokany kernel driver use following settings by default:

      • rawVolumeSerialNumber = 0x19831116
      • rawMaximumComponentLength = 256
      • rawFileSystemFlags = CaseSensitiveSearch, CasePreservedNames, SupportsRemoteStorage, UnicodeOnDisk
      • rawFileSystemNameBuffer = NTFS
      Parameters:
      rawVolumeNameBuffer -
      rawVolumeNameSize -
      rawVolumeSerialNumber -
      rawMaximumComponentLength -
      rawFileSystemFlags -
      rawFileSystemNameBuffer -
      rawFileSystemNameSize -
      dokanyFileInfo - DokanyFileInfo with information about the file or directory.
      Returns:
      NtStatus
    • mounted

      int mounted(DokanyFileInfo dokanyFileInfo)
      Is called when Dokany succeeded mounting the volume.
    • unmounted

      int unmounted(DokanyFileInfo dokanyFileInfo)
      Is called when Dokany succeeded unmounting the volume.
    • getFileSecurity

      int getFileSecurity(com.sun.jna.WString rawPath, int rawSecurityInformation, com.sun.jna.Pointer rawSecurityDescriptor, int rawSecurityDescriptorLength, com.sun.jna.ptr.IntByReference rawSecurityDescriptorLengthNeeded, DokanyFileInfo dokanyFileInfo)
      Get specified information about the security of a file or directory.

      Supported since version 0.6.0. You must specify the version in DeviceOptions.Version.

      Parameters:
      rawPath -
      rawSecurityInformation -
      rawSecurityDescriptor -
      rawSecurityDescriptorLength -
      rawSecurityDescriptorLengthNeeded -
      dokanyFileInfo - DokanyFileInfo with information about the file or directory.
      Returns:
      NtStatus
    • setFileSecurity

      int setFileSecurity(com.sun.jna.WString rawPath, int rawSecurityInformation, com.sun.jna.Pointer rawSecurityDescriptor, int rawSecurityDescriptorLength, DokanyFileInfo dokanyFileInfo)
      Sets the security of a file or directory object.

      Supported since version 0.6.0. You must specify the version in DeviceOptions.Version.

      Parameters:
      rawPath -
      rawSecurityInformation -
      rawSecurityDescriptor -
      rawSecurityDescriptorLength -
      dokanyFileInfo - DokanyFileInfo with information about the file or directory.
      Returns:
      NtStatus
    • fillWin32FindData

      void fillWin32FindData(com.sun.jna.platform.win32.WinBase.WIN32_FIND_DATA rawFillFindData, DokanyFileInfo dokanyFileInfo)
      Parameters:
      rawFillFindData -
      dokanyFileInfo - DokanyFileInfo with information about the file or directory.
    • findStreams

      int findStreams(com.sun.jna.WString rawPath, DokanyOperations.FillWin32FindStreamData rawFillFindData, DokanyFileInfo dokanyFileInfo)
      Retrieve all NTFS Streams informations on the file. This is only called if DokanOption.ALT_STREAM is enabled.
      Parameters:
      rawPath -
      rawFillFindData -
      dokanyFileInfo - DokanyFileInfo with information about the file or directory.
      Returns:
      NtStatus