private static bool AddFileToDirectory(FlashDirectory dir, string filePath) { if (!File.Exists(filePath)) { return(false); } var amfFile = new AmfFile(filePath); if (amfFile.Error != null) { switch (amfFile.Error.Type) { case AmfFileError.Error.NoPermission: Result = FileEnumerationResult.NoPermission; ResultPath = filePath; return(false); case AmfFileError.Error.Unreadable: Result = FileEnumerationResult.Unreadable; ResultPath = filePath; return(false); } } dir.Files.Add(amfFile); return(true); }
static void BuildNpapiPath(string nameFormat, string suffix, ref bool separatorBefore) { string path = ""; try { // …\AppData\Roaming path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); if (path == null) { return; } // …\AppData\Roaming\Macromedia\Flash Player\#SharedObjects path = Path.Combine(path, @"Macromedia\Flash Player\#SharedObjects\"); if (!Directory.Exists(path)) { return; } // …\AppData\Roaming\Macromedia\Flash Player\#SharedObjects\{flash_profile} var flashProfilePaths = Directory.GetDirectories(path); // …\AppData\Roaming\Macromedia\Flash Player\#SharedObjects\{flash_profile}\{suffix} var cocDirectories = new List <String>(); for (int j = 0; j < flashProfilePaths.Length; ++j) { path = Path.Combine(flashProfilePaths[j], suffix); if (Directory.Exists(path)) { cocDirectories.Add(path); } } // Create items now that we know how many of them there are. for (int i = 0; i < cocDirectories.Count; ++i) { var name = String.Format(nameFormat, cocDirectories.Count > 1 ? " #" + (i + 1) : ""); var flash = new FlashDirectory(name, cocDirectories[i], separatorBefore, DirectoryKind.Regular); separatorBefore = false; _directories.Add(flash); } } catch (SecurityException) { Result = FileEnumerationResult.NoPermission; ResultPath = path; } catch (UnauthorizedAccessException) { Result = FileEnumerationResult.NoPermission; ResultPath = path; } catch (IOException) { Result = FileEnumerationResult.Unreadable; ResultPath = path; } }
static FlashDirectory CreateExternalDirectory() { var dir = new FlashDirectory("External", "", true, DirectoryKind.Backup); foreach (var filePath in _externalPaths) { AddFileToDirectory(dir, filePath); } return(dir); }
public static FlashDirectory CreateBackupDirectory() { var dir = new FlashDirectory("Backup", BackupPath, true, DirectoryKind.Backup); var dirInfo = new DirectoryInfo(BackupPath); foreach (var filePath in dirInfo.GetFiles("*.bak").OrderByDescending(x => x.LastWriteTimeUtc).Select(x => x.FullName)) { AddFileToDirectory(dir, filePath); } return(dir); }
static FlashDirectory CreateDirectory(FlashDirectory dir) { dir = new FlashDirectory(dir.Name, dir.Path, dir.HasSeparatorBefore, DirectoryKind.Regular); if (String.IsNullOrEmpty(dir.Path)) { return(dir); } for (int i = SaveSlotsLowerBound; i <= SaveSlotsUpperBound; i++) { var filePath = Path.Combine(dir.Path, "CoC_" + i + ".sol"); AddFileToDirectory(dir, filePath); } return(dir); }
static FlashDirectory CreateExternalDirectory() { var dir = new FlashDirectory("External", "", true, DirectoryKind.Backup); foreach (var filePath in _externalPaths) { AddFileToDirectory(dir, filePath); } return dir; }
static FlashDirectory CreateDirectory(FlashDirectory dir) { dir = new FlashDirectory(dir.Name, dir.Path, dir.HasSeparatorBefore, DirectoryKind.Regular); if (String.IsNullOrEmpty(dir.Path)) return dir; for (int i = SaveSlotsLowerBound; i <= SaveSlotsUpperBound; i++) { var filePath = Path.Combine(dir.Path, "CoC_" + i + ".sol"); AddFileToDirectory(dir, filePath); } return dir; }
static void BuildPpapiPath(string nameFormat, Environment.SpecialFolder appDataPath, string appPath, string appProfilePattern, string suffix, ref bool separatorBefore) { // …\AppData\Local\Google\Chrome\User Data\{app_profile}\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects\{flash_profile}\{suffix} // …\AppData\Roaming\Opera Software\{app_profile}\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects\{flash_profile}\{suffix} Regex appProfileRegex = new Regex(appProfilePattern); string path = ""; try { // …\AppData\Local // …\AppData\Roaming var basePath = Environment.GetFolderPath(appDataPath); if (basePath == null) return; // …\AppData\Local\Google\Chrome\User Data // …\AppData\Roaming\Opera Software basePath = Path.Combine(basePath, appPath); if (!Directory.Exists(basePath)) return; // Get app profile directories. var userDataDirectories = Directory.GetDirectories(basePath); var appProfilePaths = new List<String>(); for (int i = 0; i < userDataDirectories.Length; ++i) { if (appProfileRegex.IsMatch(userDataDirectories[i])) { path = Path.Combine(basePath, userDataDirectories[i]); if (Directory.Exists(path)) appProfilePaths.Add(path); } } // Get shared object directories. var cocDirectories = new List<String>(); for (int i = 0; i < appProfilePaths.Count; ++i) { // …\AppData\Local\Google\Chrome\User Data\{app_profile} // …\AppData\Roaming\Opera Software\{app_profile} path = appProfilePaths[i]; // …\AppData\Local\Google\Chrome\User Data\{app_profile}\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects // …\AppData\Roaming\Opera Software\{app_profile}\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects path = Path.Combine(path, @"Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects\"); if (!Directory.Exists(path)) continue; // …\AppData\Local\Google\Chrome\User Data\{app_profile}\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects\{flash_profile} // …\AppData\Roaming\Opera Software\{app_profile}\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects\{flash_profile} var flashProfilePaths = Directory.GetDirectories(path); // …\AppData\Local\Google\Chrome\User Data\{app_profile}\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects\{flash_profile}\{suffix} // …\AppData\Roaming\Opera Software\{app_profile}\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects\{flash_profile}\{suffix} for (int j = 0; j < flashProfilePaths.Length; ++j) { path = Path.Combine(flashProfilePaths[j], suffix); if (Directory.Exists(path)) cocDirectories.Add(path); } } // Create items now that we know how many of them there are. for (int i = 0; i < cocDirectories.Count; ++i) { var name = String.Format(nameFormat, cocDirectories.Count > 1 ? " #" + (i + 1) : ""); var flash = new FlashDirectory(name, cocDirectories[i], separatorBefore, DirectoryKind.Regular); separatorBefore = false; _directories.Add(flash); } } catch (SecurityException) { Result = FileEnumerationResult.NoPermission; ResultPath = path; } catch (UnauthorizedAccessException) { Result = FileEnumerationResult.NoPermission; ResultPath = path; } catch (IOException) { Result = FileEnumerationResult.Unreadable; ResultPath = path; } }
static void BuildNpapiPath(string nameFormat, string suffix, ref bool separatorBefore) { string path = ""; try { // …\AppData\Roaming path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); if (path == null) return; // …\AppData\Roaming\Macromedia\Flash Player\#SharedObjects path = Path.Combine(path, @"Macromedia\Flash Player\#SharedObjects\"); if (!Directory.Exists(path)) return; // …\AppData\Roaming\Macromedia\Flash Player\#SharedObjects\{flash_profile} var flashProfilePaths = Directory.GetDirectories(path); // …\AppData\Roaming\Macromedia\Flash Player\#SharedObjects\{flash_profile}\{suffix} var cocDirectories = new List<String>(); for (int j = 0; j < flashProfilePaths.Length; ++j) { path = Path.Combine(flashProfilePaths[j], suffix); if (Directory.Exists(path)) cocDirectories.Add(path); } // Create items now that we know how many of them there are. for (int i = 0; i < cocDirectories.Count; ++i) { var name = String.Format(nameFormat, cocDirectories.Count > 1 ? " #" + (i + 1) : ""); var flash = new FlashDirectory(name, cocDirectories[i], separatorBefore, DirectoryKind.Regular); separatorBefore = false; _directories.Add(flash); } } catch (SecurityException) { Result = FileEnumerationResult.NoPermission; ResultPath = path; } catch (UnauthorizedAccessException) { Result = FileEnumerationResult.NoPermission; ResultPath = path; } catch (IOException) { Result = FileEnumerationResult.Unreadable; ResultPath = path; } }
private static bool AddFileToDirectory(FlashDirectory dir, string filePath) { if (!File.Exists(filePath)) return false; var amfFile = new AmfFile(filePath); if (amfFile.Error != null) { switch (amfFile.Error.Type) { case AmfFileError.Error.NoPermission: Result = FileEnumerationResult.NoPermission; ResultPath = filePath; return false; case AmfFileError.Error.Unreadable: Result = FileEnumerationResult.Unreadable; ResultPath = filePath; return false; } } dir.Files.Add(amfFile); return true; }
public static FlashDirectory CreateBackupDirectory() { var dir = new FlashDirectory("Backup", BackupPath, true, DirectoryKind.Backup); var dirInfo = new DirectoryInfo(BackupPath); foreach (var filePath in dirInfo.GetFiles("*.bak").OrderByDescending(x => x.LastWriteTimeUtc).Select(x => x.FullName)) { AddFileToDirectory(dir, filePath); } return dir; }
public TargetDirectoryVM(FlashDirectory directory) { _directory = directory; }
static void BuildPpapiPath(string nameFormat, Environment.SpecialFolder appDataPath, string appPath, string appProfilePattern, string suffix, ref bool separatorBefore) { // …\AppData\Local\Google\Chrome\User Data\{app_profile}\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects\{flash_profile}\{suffix} // …\AppData\Roaming\Opera Software\{app_profile}\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects\{flash_profile}\{suffix} Regex appProfileRegex = new Regex(appProfilePattern); string path = ""; try { // …\AppData\Local // …\AppData\Roaming var basePath = Environment.GetFolderPath(appDataPath); if (basePath == null) { return; } // …\AppData\Local\Google\Chrome\User Data // …\AppData\Roaming\Opera Software basePath = Path.Combine(basePath, appPath); if (!Directory.Exists(basePath)) { return; } // Get app profile directories. var userDataDirectories = Directory.GetDirectories(basePath); var appProfilePaths = new List <String>(); for (int i = 0; i < userDataDirectories.Length; ++i) { if (appProfileRegex.IsMatch(userDataDirectories[i])) { path = Path.Combine(basePath, userDataDirectories[i]); if (Directory.Exists(path)) { appProfilePaths.Add(path); } } } // Get shared object directories. var cocDirectories = new List <String>(); for (int i = 0; i < appProfilePaths.Count; ++i) { // …\AppData\Local\Google\Chrome\User Data\{app_profile} // …\AppData\Roaming\Opera Software\{app_profile} path = appProfilePaths[i]; // …\AppData\Local\Google\Chrome\User Data\{app_profile}\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects // …\AppData\Roaming\Opera Software\{app_profile}\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects path = Path.Combine(path, @"Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects\"); if (!Directory.Exists(path)) { continue; } // …\AppData\Local\Google\Chrome\User Data\{app_profile}\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects\{flash_profile} // …\AppData\Roaming\Opera Software\{app_profile}\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects\{flash_profile} var flashProfilePaths = Directory.GetDirectories(path); // …\AppData\Local\Google\Chrome\User Data\{app_profile}\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects\{flash_profile}\{suffix} // …\AppData\Roaming\Opera Software\{app_profile}\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects\{flash_profile}\{suffix} for (int j = 0; j < flashProfilePaths.Length; ++j) { path = Path.Combine(flashProfilePaths[j], suffix); if (Directory.Exists(path)) { cocDirectories.Add(path); } } } // Create items now that we know how many of them there are. for (int i = 0; i < cocDirectories.Count; ++i) { var name = String.Format(nameFormat, cocDirectories.Count > 1 ? " #" + (i + 1) : ""); var flash = new FlashDirectory(name, cocDirectories[i], separatorBefore, DirectoryKind.Regular); separatorBefore = false; _directories.Add(flash); } } catch (SecurityException) { Result = FileEnumerationResult.NoPermission; ResultPath = path; } catch (UnauthorizedAccessException) { Result = FileEnumerationResult.NoPermission; ResultPath = path; } catch (IOException) { Result = FileEnumerationResult.Unreadable; ResultPath = path; } }
static AmfFile AutoLoad(FlashDirectory[] directories) { var file = directories[0].Files[0]; VM.Instance.Load(file.FilePath, SerializationFormat.Slot, createBackup: true); return file; }
static void BuildPath(string nameFormat, Environment.SpecialFolder root, string[] middle, string suffix, ref bool separatorBefore) { var path = ""; try { // User\AppData\Roaming var basePath = Environment.GetFolderPath(root); if (basePath == null) return; var cocDirectories = new List<String>(); for (int i = 0; i < middle.Length; ++i) { path = basePath; // User\AppData\Roaming\Macromedia\Flash Player\#SharedObjects path = Path.Combine(path, middle[i]); if (!Directory.Exists(path)) continue; // User\AppData\Roaming\Macromedia\Flash Player\#SharedObjects\qsdj8HdT7 var profileDirectories = Directory.GetDirectories(path); // User\AppData\Roaming\Macromedia\Flash Player\#SharedObjects\qsdj8HdT7\localhost for (int j = 0; j < profileDirectories.Length; ++j) { path = Path.Combine(profileDirectories[j], suffix); if (Directory.Exists(path)) cocDirectories.Add(path); } } // Create items now that we know how many of them there are. for (int i = 0; i < cocDirectories.Count; ++i) { var name = String.Format(nameFormat, cocDirectories.Count > 1 ? " #" + (i + 1) : ""); var flash = new FlashDirectory(name, cocDirectories[i], separatorBefore, DirectoryKind.Regular); separatorBefore = false; _directories.Add(flash); } } catch (SecurityException) { Result = FileEnumerationResult.NoPermission; ResultPath = path; } catch (UnauthorizedAccessException) { Result = FileEnumerationResult.NoPermission; ResultPath = path; } catch (IOException) { Result = FileEnumerationResult.Unreadable; ResultPath = path; } }
static void RunSerializationTest(FlashDirectory[] directories) { Stopwatch s = new Stopwatch(); s.Start(); foreach (var first in directories[0].Files) { var outPath = "e:\\" + Path.GetFileName(first.FilePath); first.TestSerialization(); first.Save(outPath, first.Format); var input = File.ReadAllBytes(first.FilePath); var output = File.ReadAllBytes(outPath); if (input.Length != output.Length) throw new InvalidOperationException(); for (int i = 0; i < input.Length; i++) { if (input[i] != output[i]) throw new InvalidOperationException(); } } var elapsed = s.ElapsedMilliseconds; MessageBox.Show("Success!"); }
public SourceDirectoryVM(FlashDirectory directory) { _directory = directory; }