public Tasker.Conclusion CalculateRemoteDiff(Tasker tasker, Object syncObject = null) { // clean up previous directories (separate game storage vs not) tasker.SetStatus(Resources.CleaningUp); hakchi.Shell.ExecuteSimple("find \"" + (ConfigIni.Instance.UploadToTmp ? remoteTempDirectory : hakchi.RemoteGameSyncPath) + "/\" -maxdepth 1 | tail -n +2 " + "| grep -" + (ConfigIni.Instance.SeparateGameStorage ? "v" : "") + "Ee '(/hvcj-jpn?|/snes(-usa|-eur|-jpn)?|/nes(-usa|-jpn)?|/)$' " + "| while read f; do rm -rf \"$f\"; done", 0, true); // clean up symbolic links (they will be recreated if needed) hakchi.Shell.ExecuteSimple($"find \"{uploadPath}\" -type l | while read f; do rm \"$f\"; done", 0, true); // get the remote list of files, timestamps, and sizes tasker.SetStatus(Resources.CalculatingDiff); string gamesOnDevice = hakchi.Shell.ExecuteSimple($"mkdir -p \"{uploadPath}\"; cd \"{uploadPath}\"; find . -type f -exec sh -c \"stat \\\"{{}}\\\" -c \\\"%n %s %y\\\"\" \\;", 0, true); var remoteGameSet = ApplicationFileInfo.GetApplicationFileInfoFromConsoleOutput(gamesOnDevice); // delete any remote files that aren't present locally var remoteGamesToDelete = remoteGameSet.Except(localGameSet); DeleteRemoteApplicationFiles(remoteGamesToDelete, uploadPath); // only keep the local files that aren't matching on the mini transferGameSet = localGameSet.Except(remoteGameSet); return(Tasker.Conclusion.Success); }
public void SPISave(string path, ApplicationFileInfo value) { //判断是否重名,重名的话增加(数字) string directory = Path.GetDirectoryName(path); string filename = Path.GetFileNameWithoutExtension(path); string extension = Path.GetExtension(path); int counter = 1; string newFullPath = path; while (System.IO.File.Exists(newFullPath)) { string newFilename = filename + "(" + counter + ")" + extension; newFullPath = Path.Combine(directory, newFilename); counter++; } //保存 try { using (StreamWriter sr = new StreamWriter(newFullPath)) { sr.WriteLine(value); } } catch (IOException ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
public void DebugWrite() { foreach (var e in entries) { Debug.WriteLine("Filename: " + e.FileName ?? ""); if (e.ExtInfo != null) { ApplicationFileInfo.DebugListHashSet(new List <ApplicationFileInfo>() { e.ExtInfo }); } } }
public Tasker.Conclusion CalculateLocalDiff(Tasker tasker, Object syncObject = null) { // list current files on drive tasker.SetStatus(Resources.CalculatingDiff); var exportDriveGameSet = ApplicationFileInfo.GetApplicationFileInfoForDirectory(exportDirectory); // calculating diff var exportDriveGamesToDelete = exportDriveGameSet.Except(localGameSet); transferGameSet = localGameSet.Except(exportDriveGameSet); // delete any files on the device that aren't present in current layout DeleteLocalApplicationFilesFromDirectory(exportDriveGamesToDelete, exportDirectory); return(Tasker.Conclusion.Success); }