public void CopySaveGamesToSourcePort(ISourcePortData sourcePort, IFileData[] files) { foreach (IFileData file in files) { string savePath = sourcePort.GetSavePath().GetFullPath(); string fileName = Path.Combine(sourcePort.GetSavePath().GetFullPath(), file.OriginalFileName); FileInfo fiFrom = new FileInfo(Path.Combine(SaveGameDirectory.GetFullPath(), file.FileName)); try { if (fiFrom.Exists) { DirectoryInfo di = new DirectoryInfo(Path.Combine(savePath, file.OriginalFilePath)); if (!di.Exists) { di.Create(); } fiFrom.CopyTo(fileName, true); } } catch { //failed, nothing to do } } }
public void HandleUpdateSaveGames(ISourcePortData sourcePort, IGameFile gameFile, IFileData[] files) { foreach (IFileData file in files) { FileInfo fi = new FileInfo(Path.Combine(sourcePort.GetSavePath().GetFullPath(), file.OriginalFileName)); if (fi.Exists) { if (file.DateCreated == fi.LastWriteTime) { continue; } try { fi.CopyTo(Path.Combine(SaveGameDirectory.GetFullPath(), file.FileName), true); } catch { //failed, nothing to do } //check to see if the save name changed string saveName = GetSaveGameName(sourcePort, fi); if (saveName != file.Description) { file.Description = saveName; } file.DateCreated = fi.LastWriteTime; DataSourceAdapter.UpdateFile(file); } } }
private void CreateFileDetectors(ISourcePortData sourcePort) { m_screenshotDetectors = CreateDefaultScreenshotDetectors(); m_screenshotDetectors.Add(CreateScreenshotDetector(sourcePort.Directory.GetFullPath())); Array.ForEach(m_screenshotDetectors.ToArray(), x => x.StartDetection()); m_saveFileDetectors = CreateDefaultSaveGameDetectors(); m_saveFileDetectors.Add(CreateSaveGameDetector(sourcePort.GetSavePath().GetFullPath())); Array.ForEach(m_saveFileDetectors.ToArray(), x => x.StartDetection()); }
private string GetLoadLatestSave(IGameFile gameFile, ISourcePortData sourcePortData) { var saveFile = DataSourceAdapter.GetFiles(gameFile, FileType.SaveGame).Where(x => x.SourcePortID == sourcePortData.SourcePortID) .OrderByDescending(x => x.DateCreated).FirstOrDefault(); if (saveFile != null) { return(Path.Combine(sourcePortData.GetSavePath().GetFullPath(), saveFile.OriginalFileName)); } return(string.Empty); }