public int CloseFile(String filename, DokanFileInfo info) { if (info.IsDirectory) { return(0); } lock (info) { PutioFsItem item = this.FindPutioFSItem(filename); if (item == null) { return(DokanNet.ERROR_FILE_NOT_FOUND); } if (item.IsDirectory) { return(0); } PutioFileHandle handle = this.Mounter.PutioFileSystem.GetHandleByGuid((Guid)info.Context); this.Mounter.PutioFileSystem.RemoveHandle(handle); handle.Close(); info.Context = null; return(0); } }
public int GetFileInformation(String filename, FileInformation fileinfo, DokanFileInfo info) { // logger.Debug("GetFileInformation on {0} by {1}", filename, info.ProcessId); PutioFsItem item = this.FindPutioFSItem(filename); if (item == null) { return(-DokanNet.ERROR_FILE_NOT_FOUND); } else { fileinfo.Attributes = FileAttributes.Offline | FileAttributes.NotContentIndexed | FileAttributes.ReadOnly; fileinfo.CreationTime = DateTime.Now; fileinfo.LastAccessTime = DateTime.Now; fileinfo.LastWriteTime = DateTime.Now; } if (item.IsDirectory) { fileinfo.Attributes = fileinfo.Attributes | FileAttributes.Directory; fileinfo.Length = 0; } else { fileinfo.Length = ((PutioFile)item).Size; } return(0); }
public int OpenDirectory(String filename, DokanFileInfo info) { logger.Debug("OpenDirectory on {0} by {1}", filename, info.ProcessId); PutioFsItem folder = this.FindPutioFSItem(filename); if (folder != null && folder.IsDirectory) { return(0); } else { return(-DokanNet.ERROR_PATH_NOT_FOUND); } }
public int FindFiles(String filename, ArrayList files, DokanFileInfo info) { Stopwatch sw = new Stopwatch(); sw.Start(); logger.Debug("FindFiles on {0} by {1}", filename, info.ProcessId); PutioFsItem item = this.FindPutioFSItem(filename); if (item == null || !item.IsDirectory) { return(DokanNet.ERROR_PATH_NOT_FOUND); } PutioFolder folder = (PutioFolder)item; foreach (PutioFolder f in folder.GetFolders()) { FileInformation fi = new FileInformation(); fi.FileName = f.Name; fi.Attributes = FileAttributes.Offline | FileAttributes.NotContentIndexed | FileAttributes.ReadOnly | FileAttributes.Directory; fi.CreationTime = DateTime.Now; fi.LastAccessTime = DateTime.Now; fi.LastWriteTime = DateTime.Now; fi.Length = 0; files.Add(fi); } foreach (PutioFile file in folder.GetFiles()) { FileInformation fi = new FileInformation(); fi.FileName = file.Name; fi.Attributes = FileAttributes.Offline | FileAttributes.NotContentIndexed | FileAttributes.ReadOnly; fi.CreationTime = DateTime.Now; fi.LastAccessTime = DateTime.Now; fi.LastWriteTime = DateTime.Now; fi.Length = file.Size; files.Add(fi); } sw.Stop(); logger.Debug("FindFiles took {0} ms. on {1}", sw.ElapsedMilliseconds, filename); return(0); }
public int CreateFile(String filename, FileAccess access, FileShare share, FileMode mode, FileOptions options, DokanFileInfo info) { lock (info) { if (access != FileAccess.Read) { return(-DokanNet.ERROR_ACCESS_DENIED); } PutioFsItem fs_item = this.FindPutioFSItem(filename); if (fs_item == null) { return(-DokanNet.ERROR_FILE_NOT_FOUND); } if (fs_item.IsDirectory) { info.IsDirectory = true; } else { PutioFile putio_file = (PutioFile)fs_item; // if (putio_file.ReachedHandleLimit()) // return DokanNet.ERROR_SHARING_VIOLATION; PutioFileHandle handle = putio_file.Open(); this.Mounter.PutioFileSystem.AddHandle(handle); info.Context = handle.Guid; logger.Debug("CreateFile: {0} - {1}", filename, handle); } return(0); } }