private void ProcessRenameNewName(PInvokeWin32.USN_RECORD usn, string volume, MyEverythingDB db) { // frn 没有改变 // newname = usn.FileName // 根据usn.FRN可以从db中获取oldname // db.update... MyEverythingRecord newRecord = MyEverythingRecord.ParseUSN(usn); string fullpath = newRecord.Name; db.FindRecordPath(newRecord, ref fullpath, db.GetFolderSource(volume)); newRecord.FullPath = fullpath; var oldRecord = db.FindByFrn(volume, usn.FRN); string newname = newRecord.FullPath; Debug.WriteLine(string.Format(">>>> RenameFile {0} to {1}", oldRecord.FullPath, newname)); db.UpdateRecord(volume, newRecord, usn.IsFolder ? MyEverythingRecordType.Folder : MyEverythingRecordType.File); if (RecordRenameEvent != null) { RecordRenameEvent(oldRecord, newRecord); } if (newname.Contains("$RECYCLE.BIN")) { Debug.WriteLine(string.Format(">>>> Means {0} moved to recycle.", oldRecord.FullPath)); } }
public void BuildPath() { foreach (var pair in _volumes_files) { var fileRecords = pair.Value.Values.ToList(); var fldSource = _volumes_folders[pair.Key]; foreach (MyEverythingRecord file in fileRecords) { string fullpath = file.Name; MyEverythingRecord fstDir = null; if (fldSource.TryGetValue(file.ParentFrn, out fstDir)) { if (fstDir.IsVolumeRoot) // 针对根目录下的文件 { file.FullPath = string.Format("{0}{1}{2}", fstDir.Name, Path.DirectorySeparatorChar, fullpath); } else { FindRecordPath(fstDir, ref fullpath, fldSource); file.FullPath = fullpath; } } else { file.FullPath = fullpath; } } } }
public static void ConvertFrn2FullPath(List <MyEverythingRecord> fileRecords, Dictionary <ulong, MyEverythingRecord> dirSource) { foreach (MyEverythingRecord file in fileRecords) { string fullpath = file.Name; MyEverythingRecord fstDir = null; if (dirSource.TryGetValue(file.ParentFrn, out fstDir)) { if (fstDir.IsVolumeRoot) // 针对根目录下的文件 { file.FullPath = string.Format("{0}{1}{2}", fstDir.Name, Path.DirectorySeparatorChar, fullpath); } else { FindPath(fstDir, ref fullpath, dirSource); file.FullPath = fullpath; } } else { file.FullPath = fullpath; //Console.WriteLine("Can't find {0}'s parent folder.", file.Name); } } var t1 = fileRecords.Where(x => x.Name == "guestbook.js").FirstOrDefault(); }
public static void FillPath(string volume, MyEverythingRecord record, MyEverythingDB db) { if (record == null) return; var fdSource = db.GetFolderSource(volume); string fullpath = record.Name; FindRecordPath(record, ref fullpath, fdSource); record.FullPath = fullpath; }
public void AddRecord(string volume, MyEverythingRecord record, MyEverythingRecordType type) { if (type == MyEverythingRecordType.File) { CheckHashTableKey(_volumes_files, volume); _volumes_files[volume].Add(record.FRN, record); } else { CheckHashTableKey(_volumes_folders, volume); _volumes_folders[volume].Add(record.FRN, record); } }
public void UpdateRecord(string volume, MyEverythingRecord record, MyEverythingRecordType type) { if (type == MyEverythingRecordType.File) { RealUpdateRecord(volume, _volumes_files, record); } else { RealUpdateRecord(volume, _volumes_folders, record); } }
public static void FillPath(string volume, MyEverythingRecord record, MyEverythingDB db) { if (record == null) { return; } var fdSource = db.GetFolderSource(volume); string fullpath = record.Name; FindRecordPath(record, ref fullpath, fdSource); record.FullPath = fullpath; }
private void ProcessFileCreate(PInvokeWin32.USN_RECORD usn, string volume, MyEverythingDB db) { MyEverythingRecord record = MyEverythingRecord.ParseUSN(usn); string fullpath = record.Name; db.FindRecordPath(record, ref fullpath, db.GetFolderSource(volume)); record.FullPath = fullpath; db.AddRecord(volume, record, usn.IsFolder ? MyEverythingRecordType.Folder : MyEverythingRecordType.File); Debug.WriteLine(string.Format(">>>> NewFile: {0}", record.FullPath)); if (RecordAddedEvent != null) { RecordAddedEvent(record); } }
private static void FindRecordPath(MyEverythingRecord curRecord, ref string fullpath, Dictionary <ulong, MyEverythingRecord> fdSource) { if (curRecord.IsVolumeRoot) { return; } MyEverythingRecord nextRecord = null; if (!fdSource.TryGetValue(curRecord.ParentFrn, out nextRecord)) { return; } fullpath = string.Format("{0}{1}{2}", nextRecord.Name, Path.DirectorySeparatorChar, fullpath); FindRecordPath(nextRecord, ref fullpath, fdSource); }
public MyEverythingRecord FindByFrn(string volume, ulong frn) { if ((!_volumes_files.ContainsKey(volume)) || (!_volumes_folders.ContainsKey(volume))) { throw new Exception(string.Format("DB not contain the volume: {0}", volume)); } MyEverythingRecord result = null; _volumes_files[volume].TryGetValue(frn, out result); if (result != null) { return(result); } _volumes_folders[volume].TryGetValue(frn, out result); return(result); }
private bool RealUpdateRecord(string volume, Dictionary<string, Dictionary<ulong, MyEverythingRecord>> source, MyEverythingRecord record) { if (source.ContainsKey(volume) && source[volume].ContainsKey(record.FRN)) { source[volume][record.FRN] = record; return true; } else { return false; } }
public void UpdateRecord(string volume, MyEverythingRecord record, MyEverythingRecordType type) { if (type == MyEverythingRecordType.File) RealUpdateRecord(volume, _volumes_files, record); else RealUpdateRecord(volume, _volumes_folders, record); }
private static void FindRecordPath(MyEverythingRecord curRecord, ref string fullpath, Dictionary<ulong, MyEverythingRecord> fdSource) { if (curRecord.IsVolumeRoot) return; MyEverythingRecord nextRecord = null; if (!fdSource.TryGetValue(curRecord.ParentFrn, out nextRecord)) return; fullpath = string.Format("{0}{1}{2}", nextRecord.Name, Path.DirectorySeparatorChar, fullpath); FindRecordPath(nextRecord, ref fullpath, fdSource); }
private bool RealUpdateRecord(string volume, Dictionary <string, Dictionary <ulong, MyEverythingRecord> > source, MyEverythingRecord record) { if (source.ContainsKey(volume) && source[volume].ContainsKey(record.FRN)) { source[volume][record.FRN] = record; return(true); } else { return(false); } }