コード例 #1
0
ファイル: FileManager.cs プロジェクト: klorpa/CoCEd
        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);
        }
コード例 #2
0
ファイル: FileManager.cs プロジェクト: klorpa/CoCEd
        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;
            }
        }
コード例 #3
0
ファイル: FileManager.cs プロジェクト: klorpa/CoCEd
        static FlashDirectory CreateExternalDirectory()
        {
            var dir = new FlashDirectory("External", "", true, DirectoryKind.Backup);

            foreach (var filePath in _externalPaths)
            {
                AddFileToDirectory(dir, filePath);
            }
            return(dir);
        }
コード例 #4
0
ファイル: FileManager.cs プロジェクト: klorpa/CoCEd
        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);
        }
コード例 #5
0
ファイル: FileManager.cs プロジェクト: klorpa/CoCEd
        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);
        }
コード例 #6
0
ファイル: FileManager.cs プロジェクト: Belgrath/CoCEd
 static FlashDirectory CreateExternalDirectory()
 {
     var dir = new FlashDirectory("External", "", true, DirectoryKind.Backup);
     foreach (var filePath in _externalPaths)
     {
         AddFileToDirectory(dir, filePath);
     }
     return dir;
 }
コード例 #7
0
ファイル: FileManager.cs プロジェクト: Belgrath/CoCEd
        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;
        }
コード例 #8
0
ファイル: FileManager.cs プロジェクト: Belgrath/CoCEd
        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;
            }
        }
コード例 #9
0
ファイル: FileManager.cs プロジェクト: Belgrath/CoCEd
        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;
            }
        }
コード例 #10
0
ファイル: FileManager.cs プロジェクト: Belgrath/CoCEd
        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;
        }
コード例 #11
0
ファイル: FileManager.cs プロジェクト: Belgrath/CoCEd
        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;
        }
コード例 #12
0
ファイル: FilesVM.cs プロジェクト: Belgrath/CoCEd
 public TargetDirectoryVM(FlashDirectory directory)
 {
     _directory = directory;
 }
コード例 #13
0
ファイル: FileManager.cs プロジェクト: klorpa/CoCEd
        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;
            }
        }
コード例 #14
0
ファイル: App.xaml.cs プロジェクト: tmedwards/CoCEd
 static AmfFile AutoLoad(FlashDirectory[] directories)
 {
     var file = directories[0].Files[0];
     VM.Instance.Load(file.FilePath, SerializationFormat.Slot, createBackup: true);
     return file;
 }
コード例 #15
0
ファイル: FileManager.cs プロジェクト: ambjoorn94/CoCEd
        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;
            }
        }
コード例 #16
0
ファイル: App.xaml.cs プロジェクト: tmedwards/CoCEd
        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!");
        }
コード例 #17
0
ファイル: FilesVM.cs プロジェクト: Belgrath/CoCEd
 public SourceDirectoryVM(FlashDirectory directory)
 {
     _directory = directory;
 }