public int Cleanup(string filename, DokanFileInfo info) { lock (_syncObj) { FileHandle handle = (FileHandle)info.Context; if (handle != null) { handle.Cleanup(); } return(DokanNet.DOKAN_SUCCESS); } }
public void CloseFile(string filename, DokanFileInfo info) { lock (_syncObj) { FileHandle handle = info.Context as FileHandle; if (handle != null) { handle.Resource.RemoveFileHandle(handle); } info.Context = null; } }
public int CloseFile(string filename, DokanFileInfo info) { lock (_syncObj) { FileHandle handle = (FileHandle)info.Context; if (handle != null) { handle.Resource.RemoveFileHandle(handle); } info.Context = null; return(DokanNet.DOKAN_SUCCESS); } }
public int OpenDirectory(string filename, DokanFileInfo info) { lock (_syncObj) { VirtualFileSystemResource resource = ParseFileName(filename); if (resource == null || !(resource is VirtualBaseDirectory)) { return(-DokanNet.ERROR_PATH_NOT_FOUND); } FileHandle handle = new FileHandle(resource); info.Context = handle; resource.AddFileHandle(handle); return(DokanNet.DOKAN_SUCCESS); } }
public int CreateFile(string filename, FileAccess access, FileShare share, FileMode mode, FileOptions options, DokanFileInfo info) { lock (_syncObj) { VirtualFileSystemResource resource = ParseFileName(filename); if (resource == null) { return(-DokanNet.ERROR_FILE_NOT_FOUND); } FileHandle handle = new FileHandle(resource); info.Context = handle; resource.AddFileHandle(handle); if (resource is VirtualBaseDirectory) { info.IsDirectory = true; // Necessary for the Dokan driver to set this, see docs } return(DokanNet.DOKAN_SUCCESS); } }
public NtStatus CreateFile(string filename, FileAccess access, FileShare share, FileMode mode, FileOptions options, FileAttributes attributes, DokanFileInfo info) { lock (_syncObj) { VirtualFileSystemResource resource = ParseFileName(filename); if (resource == null) { return(DokanResult.Error); } FileHandle handle = new FileHandle(resource); info.Context = handle; resource.AddFileHandle(handle); if (resource is VirtualBaseDirectory) { info.IsDirectory = true; } return(DokanResult.Success); } }
public NtStatus ReadFile(string filename, byte[] buffer, out int bytesRead, long offset, DokanFileInfo info) { FileHandle handle = info.Context as FileHandle; Stream stream; bytesRead = 0; lock (_syncObj) { if (handle == null) { return(DokanResult.FileNotFound); } try { stream = handle.GetOrOpenStream(); if (stream == null) { return(DokanResult.FileNotFound); } } catch (Exception e) { ServiceRegistration.Get <ILogger>().Warn("Dokan: Error creating file stream of resource '{0}'", e, handle.Resource); return(DokanResult.Error); } } // Do the reading outside the lock - might block when not enough bytes are available try { stream.Seek(offset, SeekOrigin.Begin); bytesRead = stream.Read(buffer, 0, buffer.Length); return(DokanResult.Success); } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Warn("Dokan: Error reading from stream of resource '{0}'", ex, handle.Resource); return(DokanResult.Error); } }
public int ReadFile(string filename, byte[] buffer, ref uint readBytes, long offset, DokanFileInfo info) { FileHandle handle = (FileHandle)info.Context; Stream stream; lock (_syncObj) { if (handle == null) { return(-DokanNet.ERROR_FILE_NOT_FOUND); } try { stream = handle.GetOrOpenStream(); if (stream == null) { return(-DokanNet.ERROR_FILE_NOT_FOUND); } } catch (Exception e) { ServiceRegistration.Get <ILogger>().Warn("Dokan: Error creating file stream of resource '{0}'", e, handle.Resource); return(DokanNet.DOKAN_ERROR); } } // Do the reading outside the lock - might block when not enough bytes are available try { stream.Seek(offset, SeekOrigin.Begin); readBytes = (uint)stream.Read(buffer, 0, buffer.Length); return(DokanNet.DOKAN_SUCCESS); } catch (Exception e) { ServiceRegistration.Get <ILogger>().Warn("Dokan: Error reading from stream of resource '{0}'", e, handle.Resource); return(DokanNet.DOKAN_ERROR); } }
public void RemoveFileHandle(FileHandle handle) { _fileHandles.Remove(handle); }
public void AddFileHandle(FileHandle handle) { _fileHandles.Add(handle); }
public int OpenDirectory(string filename, DokanFileInfo info) { lock (_syncObj) { VirtualFileSystemResource resource = ParseFileName(filename); if (resource == null || !(resource is VirtualBaseDirectory)) return -DokanNet.ERROR_PATH_NOT_FOUND; FileHandle handle = new FileHandle(resource); info.Context = handle; resource.AddFileHandle(handle); return DokanNet.DOKAN_SUCCESS; } }
public int CreateFile(string filename, FileAccess access, FileShare share, FileMode mode, FileOptions options, DokanFileInfo info) { lock (_syncObj) { VirtualFileSystemResource resource = ParseFileName(filename); if (resource == null) return -DokanNet.ERROR_FILE_NOT_FOUND; FileHandle handle = new FileHandle(resource); info.Context = handle; resource.AddFileHandle(handle); if (resource is VirtualBaseDirectory) info.IsDirectory = true; // Necessary for the Dokan driver to set this, see docs return DokanNet.DOKAN_SUCCESS; } }