public FindByFrn ( string volume, ulong frn ) : |
||
volume | string | |
frn | ulong | |
리턴 |
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)); } }
private void ProcessFileDelete(PInvokeWin32.USN_RECORD usn, string volume, MyEverythingDB db) { var cached = db.FindByFrn(volume, usn.FRN); if (cached == null) { return; } else { var isdelete = db.DeleteRecord(volume, usn.FRN); Debug.WriteLine(string.Format(">>>> File {0} deleted {1}.", cached.FullPath, isdelete ? "successful" : "fail")); if (RecordDeletedEvent != null) { RecordDeletedEvent(cached); } } }
private void ProcessUSN(PInvokeWin32.USN_RECORD usn, string volume, MyEverythingDB db) { var dbCached = db.FindByFrn(volume, usn.FRN); Debug.WriteLine(string.Format("------USN[frn={0}]------", usn.FRN)); Debug.WriteLine(string.Format("FileName={0}, Reason={1}", usn.FileName, Reason.ReasonPrettyFormat(usn.Reason))); Debug.WriteLine(string.Format("FileName[Cached]={0}", dbCached == null ? "NoCache": dbCached.FullPath)); Debug.WriteLine("--------------------------------------"); if (Util.MaskEqual(usn.Reason, Reason.USN_REASONS["USN_REASON_RENAME_NEW_NAME"])) { ProcessRenameNewName(usn, volume, db); } if ((usn.Reason & Reason.USN_REASONS["USN_REASON_FILE_CREATE"]) != 0) { ProcessFileCreate(usn, volume, db); } if (Util.MaskEqual(usn.Reason, Reason.USN_REASONS["USN_REASON_FILE_DELETE"])) { ProcessFileDelete(usn, volume, db); } }
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)); } }
private void ProcessFileDelete(PInvokeWin32.USN_RECORD usn, string volume, MyEverythingDB db) { var cached = db.FindByFrn(volume, usn.FRN); if (cached == null) { return; } else { var isdelete = db.DeleteRecord(volume, usn.FRN); Debug.WriteLine(string.Format(">>>> File {0} deleted {1}.", cached.FullPath, isdelete ? "successful" : "fail")); if (RecordDeletedEvent != null) RecordDeletedEvent(cached); } }
private void ProcessUSN(PInvokeWin32.USN_RECORD usn, string volume, MyEverythingDB db) { var dbCached = db.FindByFrn(volume, usn.FRN); Debug.WriteLine(string.Format("------USN[frn={0}]------", usn.FRN)); Debug.WriteLine(string.Format("FileName={0}, Reason={1}", usn.FileName, Reason.ReasonPrettyFormat(usn.Reason))); Debug.WriteLine(string.Format("FileName[Cached]={0}", dbCached == null ? "NoCache": dbCached.FullPath)); Debug.WriteLine("--------------------------------------"); if (Util.MaskEqual(usn.Reason, Reason.USN_REASONS["USN_REASON_RENAME_NEW_NAME"])) ProcessRenameNewName(usn, volume, db); if ((usn.Reason & Reason.USN_REASONS["USN_REASON_FILE_CREATE"]) != 0) ProcessFileCreate(usn, volume, db); if (Util.MaskEqual(usn.Reason, Reason.USN_REASONS["USN_REASON_FILE_DELETE"])) ProcessFileDelete(usn, volume, db); }