Interface DokanyFileSystem
- All Known Implementing Classes:
ReadWriteAdapter
-
Method Summary
Modifier and TypeMethodDescriptionvoidcleanup(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).voidcloseFile(com.sun.jna.WString rawPath, DokanyFileInfo dokanyFileInfo) CloseFile is called at the end of the life of the context.intdeleteDirectory(com.sun.jna.WString rawPath, DokanyFileInfo dokanyFileInfo) Check if it is possible to delete a directory.intdeleteFile(com.sun.jna.WString rawPath, DokanyFileInfo dokanyFileInfo) Check if it is possible to delete a file.voidfillWin32FindData(com.sun.jna.platform.win32.WinBase.WIN32_FIND_DATA rawFillFindData, DokanyFileInfo dokanyFileInfo) intfindFiles(com.sun.jna.WString rawPath, DokanyOperations.FillWin32FindData rawFillFindData, DokanyFileInfo dokanyFileInfo) List all files in the path requested.intfindFilesWithPattern(com.sun.jna.WString fileName, com.sun.jna.WString searchPattern, DokanyOperations.FillWin32FindData rawFillFindData, DokanyFileInfo dokanyFileInfo) Same asfindFiles(WString, DokanyOperations.FillWin32FindData, DokanyFileInfo)but with a search pattern to filter the result.intfindStreams(com.sun.jna.WString rawPath, DokanyOperations.FillWin32FindStreamData rawFillFindData, DokanyFileInfo dokanyFileInfo) Retrieve all NTFS Streams informations on the file.intflushFileBuffers(com.sun.jna.WString rawPath, DokanyFileInfo dokanyFileInfo) Clears buffers for this context and causes any buffered data to be written to the file.intgetDiskFreeSpace(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.intgetFileInformation(com.sun.jna.WString fileName, ByHandleFileInfo handleFileInfo, DokanyFileInfo dokanyFileInfo) Get specific informations on a file.intgetFileSecurity(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.intgetVolumeInformation(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.intlockFile(com.sun.jna.WString rawPath, long rawByteOffset, long rawLength, DokanyFileInfo dokanyFileInfo) Lock file at a specific offset and data length.intmounted(DokanyFileInfo dokanyFileInfo) Is called when Dokany succeeded mounting the volume.intmoveFile(com.sun.jna.WString rawPath, com.sun.jna.WString rawNewFileName, boolean rawReplaceIfExisting, DokanyFileInfo dokanyFileInfo) Move a file or directory to a new location.intreadFile(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 inzwCreateFile(WString, WinBase.SECURITY_ATTRIBUTES, int, int, int, int, int, DokanyFileInfo).intsetAllocationSize(com.sun.jna.WString rawPath, long rawLength, DokanyFileInfo dokanyFileInfo) SetAllocationSize is used to truncate or extend a file.intsetEndOfFile(com.sun.jna.WString rawPath, long rawByteOffset, DokanyFileInfo dokanyFileInfo) SetEndOfFile is used to truncate or extend a file (physical file size).intsetFileAttributes(com.sun.jna.WString rawPath, int rawAttributes, DokanyFileInfo dokanyFileInfo) Set file attributes on a specific file.intsetFileSecurity(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.intsetFileTime(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.intunlockFile(com.sun.jna.WString rawPath, long rawByteOffset, long rawLength, DokanyFileInfo dokanyFileInfo) Unlock file at a specific offset and data length.intunmounted(DokanyFileInfo dokanyFileInfo) Is called when Dokany succeeded unmounting the volume.intwriteFile(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 inzwCreateFile(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.intzwCreateFile(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 returnNtStatus.SUCCESSwhen that directory can be opened andDokanyFileInfo.IsDirectoryhas to be set to TRUE. On the other hand, ifDokanyFileInfo.IsDirectoryis set to TRUE but the path targets a file,NtStatus.NOT_A_DIRECTORYmust be returned.DokanyFileInfo.Contextcan 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 incleanup(WString, DokanyFileInfo).- Parameters:
rawPath- Path requested by the Kernel on the File System. TODO: rewrite this parameter description to link to winBasesecurityContext- 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_MASKrawFileAttributes- 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 viaCreationDispositionrawCreateOptions- Specifies the options to apply when the driver creates or opens the file. (see also in the .NET API System.IO.FileOptions)dokanyFileInfo-DokanyFileInfowith information about the file or directory.- Returns:
- integer code of a
NtStatus - See Also:
-
cleanup
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-DokanyFileInfowith information about the file or directory.
-
closeFile
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 inDokanyFileInfo.Contexthas to be cleared before return.- Parameters:
rawPath-dokanyFileInfo-DokanyFileInfowith 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 inzwCreateFile(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-DokanyFileInfowith 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 inzwCreateFile(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-DokanyFileInfowith information about the file or directory.- Returns:
NtStatus
-
flushFileBuffers
Clears buffers for this context and causes any buffered data to be written to the file.- Parameters:
rawPath-dokanyFileInfo-DokanyFileInfowith 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-DokanyFileInfowith 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-DokanyFileInfowith 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 asfindFiles(WString, DokanyOperations.FillWin32FindData, DokanyFileInfo)but with a search pattern to filter the result.- Parameters:
fileName-searchPattern-rawFillFindData-dokanyFileInfo-DokanyFileInfowith 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-DokanyFileInfowith 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 directoryrawCreationTime- time of creationrawLastAccessTime- time of last accessrawLastWriteTime- time of last modificationdokanyFileInfo-DokanyFileInfowith information about the file or directory.- Returns:
NtStatus
-
deleteFile
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 asNtStatus.ACCESS_DENIED,NtStatus.OBJECT_NO_LONGER_EXISTS,NtStatus.OBJECT_NAME_NOT_FOUND.deleteFile(WString, DokanyFileInfo)will also be called withDokanyFileInfo.DeleteOnCloseset to false to notify the driver when the file is no longer requested to be deleted.When you return
NtStatus.SUCCESS, you get acleanup(WString, DokanyFileInfo)call afterwards withDokanyFileInfo.DeleteOnCloseset to true and only then you have to actually delete the file being closed.- Parameters:
rawPath-dokanyFileInfo-DokanyFileInfowith information about the file.- Returns:
NtStatus- See Also:
-
deleteDirectory
Check if it is possible to delete a directory.- Parameters:
rawPath-dokanyFileInfo-DokanyFileInfowith 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-DokanyFileInfowith information about the file or directory.- Returns:
NtStatus
-
setEndOfFile
SetEndOfFile is used to truncate or extend a file (physical file size).- Parameters:
rawPath-rawByteOffset-dokanyFileInfo-DokanyFileInfowith information about the file or directory.- Returns:
NtStatus
-
setAllocationSize
SetAllocationSize is used to truncate or extend a file.- Parameters:
rawPath-rawLength-dokanyFileInfo-DokanyFileInfowith 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 ifDokanOption.FILELOCK_USER_MODEis enabled.- Parameters:
rawPath-rawByteOffset-rawLength-dokanyFileInfo-DokanyFileInfowith 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 ifDokanOption.FILELOCK_USER_MODEis enabled.- Parameters:
rawPath-rawByteOffset-rawLength-dokanyFileInfo-DokanyFileInfowith 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 theDokanyFileInfo.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-DokanyFileInfowith 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 theDokanyFileInfo.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_VOLUMEis automatically added to the features ifDokanOption.WRITE_PROTECTIONwas specified during mount.If
NtStatus.NOT_IMPLEMENTEDis 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-DokanyFileInfowith information about the file or directory.- Returns:
NtStatus
-
mounted
Is called when Dokany succeeded mounting the volume. -
unmounted
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-DokanyFileInfowith 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-DokanyFileInfowith 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-DokanyFileInfowith 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 ifDokanOption.ALT_STREAMis enabled.- Parameters:
rawPath-rawFillFindData-dokanyFileInfo-DokanyFileInfowith information about the file or directory.- Returns:
NtStatus
-