public void RemoveFindFilesCache() { System.Diagnostics.Debug.WriteLine("RemoveFindFilesCache " + Name); FindFilesRet = DokanError.Undefined; FindFilesValue = null; Children = null; }
protected DokanError PopulateNDEFFiles(IList <FileInformation> files, string parentName = null) { log.Info("PopulateNDEFFiles call"); if (CacheCount() == 0) { log.Info("No cache yet, building cache list..."); DokanError payloadRet = ReadAndCachePayload(parentName); if (payloadRet != DokanError.ErrorSuccess) { return(payloadRet); } } foreach (string filename in cacheFiles.Keys) { log.Info(String.Format("Found file {0}", filename)); FileInformation ndefFile = new FileInformation(); ndefFile.Attributes = FileAttributes.Normal; ndefFile.FileName = Path.GetFileName(filename); ndefFile.CreationTime = ndefFile.LastWriteTime = cacheFiles[filename].LastModificationDate; ndefFile.LastAccessTime = cacheFiles[filename].LastAccessDate; ndefFile.Length = cacheFiles[filename].Data.Length; files.Add(ndefFile); } return(DokanError.ErrorSuccess); }
public DokanError FindFiles(string filename, out IList <FileInformation> files, DokanFileInfo info) { CacheEntry entry = cache_.Lookup(filename); DokanError ret = 0; if (entry.FindFilesRet == DokanError.Undefined) { ret = ope_.FindFiles(filename, out files, info); entry.FindFilesRet = ret; entry.FindFilesValue = files; } else { files = new List <FileInformation>(); IList <FileInformation> cfiles = entry.FindFilesValue; foreach (FileInformation e in cfiles) { files.Add(e); } ret = entry.FindFilesRet; } return(ret); }
public DokanError GetFileInformation(string filename, out FileInformation fileinfo, DokanFileInfo info) { CacheEntry entry = cache_.Lookup(filename); DokanError ret = 0; if (entry.GetFileInfoRet == DokanError.Undefined) { ret = ope_.GetFileInformation(filename, out fileinfo, info); entry.GetFileInfoRet = ret; entry.GetFileInfoValue = fileinfo; } else { FileInformation finfo = entry.GetFileInfoValue; fileinfo = new FileInformation(); fileinfo.Attributes = finfo.Attributes; fileinfo.CreationTime = finfo.CreationTime; fileinfo.FileName = finfo.FileName; fileinfo.LastAccessTime = finfo.LastAccessTime; fileinfo.LastWriteTime = finfo.LastWriteTime; fileinfo.Length = finfo.Length; ret = entry.GetFileInfoRet; } return(ret); }
public DokanError CreateFile(string filename, DokanNet.FileAccess access, FileShare share, FileMode mode, FileOptions options, FileAttributes attributes, DokanFileInfo info) { DokanError ret = DokanError.ErrorSuccess; if (filename.EndsWith(":SSHFSProperty.Cache")) { System.Diagnostics.Debug.WriteLine("SSHFS.Cache: " + filename); filename = filename.Remove(filename.IndexOf(":SSHFSProperty.Cache")); CacheEntry entry = cache_.Lookup(filename); entry.RemoveAllCache(); return(DokanError.ErrorSuccess); } if (mode == FileMode.Open || mode == FileMode.OpenOrCreate) { CacheEntry entry = cache_.Lookup(filename); if (mode == FileMode.OpenOrCreate) { if (entry.Parrent != null) { entry.Parrent.RemoveFindFilesCache(); } } if (entry.CreateFileRet == DokanError.Undefined) { ret = ope_.CreateFile(filename, access, share, mode, options, attributes, info); entry.CreateFileRet = ret; } else { ret = entry.CreateFileRet; } } else { ret = ope_.CreateFile(filename, access, share, mode, options, attributes, info); if (mode == FileMode.Create || mode == FileMode.CreateNew) { CacheEntry entry = cache_.Lookup(filename); if (entry.Parrent != null) { entry.Parrent.RemoveFindFilesCache(); } } } return(ret); }
public DokanError OpenDirectory(string filename, DokanFileInfo info) { DokanError ret = 0; CacheEntry entry = cache_.Lookup(filename); if (entry.OpenDirectoryRet == DokanError.Undefined) { ret = ope_.OpenDirectory(filename, info); entry.OpenDirectoryRet = ret; } else { ret = entry.OpenDirectoryRet; } return(ret); }
protected DokanError ReadAndCachePayload(string parentName) { byte[] payload = null; string extension = String.Empty; DokanError payloadRet = ReadPayload(out payload, out extension); if (payloadRet != DokanError.ErrorSuccess) { log.Error("Error reading payload"); return(payloadRet); } if (payload != null) { string filename = "\\record"; if (!String.IsNullOrEmpty(extension)) { filename += "." + extension; if (extension == "url") { string lnk = "[InternetShortcut]" + Environment.NewLine; lnk += "URL=" + Encoding.ASCII.GetString(payload) + Environment.NewLine; payload = Encoding.ASCII.GetBytes(lnk); } } if (!String.IsNullOrEmpty(parentName)) { filename = parentName + filename; } InitCache(filename); WriteToCache(filename, payload); log.Info(String.Format("Record cached as {0}", filename)); } return(DokanError.ErrorSuccess); }
public override DokanError CreateFile(string fileName, FileAccess access, FileShare share, FileMode mode, FileOptions options, FileAttributes attributes, DokanFileInfo info) { log.Info(String.Format("CreateFile call - {0}", fileName)); IChip chip = rfidListener.GetChip(); if (chip == null) { return(DokanError.ErrorNotReady); } info.Context = new RFIDContext(); if (fileName == "\\" || (attributes & FileAttributes.Directory) != 0) { if (!CheckDirectoryPath(fileName)) { log.Error("Path not found"); return(DokanError.ErrorFileNotFound); } return(DokanError.ErrorSuccess); } else { bool exists = false; lock (cacheFiles) { if (!CacheExists(fileName)) { if (CacheCount() > 0) { log.Error("Cache already initialized and cannot found file"); return(DokanError.ErrorFileNotFound); } DokanError payloadRet = ReadAndCachePayload(nfcConfig.CSNAsRoot ? "\\" + chip.ChipIdentifier : String.Empty); if (payloadRet == DokanError.ErrorSuccess) { exists = CacheExists(fileName); } else { return(payloadRet); } } else { exists = true; } } log.Info(String.Format("Exists? {0}", exists)); switch (mode) { case FileMode.Open: { log.Info("FileMode Open"); if (exists) { return(DokanError.ErrorSuccess); } else { log.Error("File not found."); return(DokanError.ErrorFileNotFound); } } case FileMode.CreateNew: { log.Info("FileMode CreateNew"); if (exists) { return(DokanError.ErrorAlreadyExists); } InitCache(fileName); return(DokanError.ErrorSuccess); } case FileMode.Create: { log.Info("FileMode Create"); InitCache(fileName); return(DokanError.ErrorSuccess); } case FileMode.OpenOrCreate: { log.Info("FileMode OpenOrCreate"); if (!exists) { InitCache(fileName); } return(DokanError.ErrorSuccess); } case FileMode.Truncate: { log.Info("FileMode Truncate"); if (!exists) { return(DokanError.ErrorFileNotFound); } InitCache(fileName); return(DokanError.ErrorSuccess); } case FileMode.Append: { log.Info("FileMode Append"); if (!exists) { return(DokanError.ErrorFileNotFound); } return(DokanError.ErrorSuccess); } default: { log.Error(String.Format("Error unknown FileMode {0}", mode)); return(DokanError.ErrorError); } } } }
public void RemoveGetFileInfoCache() { GetFileInfoRet = DokanError.Undefined; GetFileInfoValue = new FileInformation(); }
public void RemoveOpenDirectoryCache() { OpenDirectoryRet = DokanError.Undefined; }
public void RemoveCreateFileCache() { CreateFileRet = DokanError.Undefined; }