Beispiel #1
0
        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);
        }
Beispiel #2
0
        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 titsDirectories = new List <String>();
                for (int j = 0; j < flashProfilePaths.Length; ++j)
                {
                    path = Path.Combine(flashProfilePaths[j], suffix);
                    if (Directory.Exists(path))
                    {
                        titsDirectories.Add(path);
                    }
                }

                // Create items now that we know how many of them there are.
                for (int i = 0; i < titsDirectories.Count; ++i)
                {
                    var name  = String.Format(nameFormat, titsDirectories.Count > 1 ? " #" + (i + 1) : "");
                    var flash = new FlashDirectory(name, titsDirectories[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;
            }
        }
Beispiel #3
0
        static FlashDirectory CreateExternalDirectory()
        {
            var dir = new FlashDirectory("External", "", true, DirectoryKind.Backup);

            foreach (var filePath in _externalPaths)
            {
                AddFileToDirectory(dir, filePath);
            }
            return(dir);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        static FlashDirectory CreateExternalDirectory()
        {
            Logger.Trace("CreateExternalDirectory:Begin");

            var dir = new FlashDirectory("External", "", true, DirectoryKind.External);

            foreach (var filePath in _externalPaths)
            {
                AddFileToDirectory(dir, filePath);
            }

            Logger.Trace(String.Format("CreateExternalDirectory:End {0}", dir));
            return(dir);
        }
Beispiel #6
0
        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, "TiTs_" + i + ".sol");
                AddFileToDirectory(dir, filePath);
            }
            return(dir);
        }
Beispiel #7
0
        public static FlashDirectory CreateBackupDirectory()
        {
            Logger.Trace("CreateBackupDirectory:Begin");

            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);
            }

            Logger.Trace(String.Format("CreateBackupDirectory:End {0}", dir));
            return(dir);
        }
Beispiel #8
0
        private static bool AddFileToDirectory(FlashDirectory dir, string filePath)
        {
            Logger.Trace(String.Format("AddFileToDirectory({0},{1})", dir, filePath));

            bool added = false;

            if (File.Exists(filePath))
            {
                var amfFile = new AmfFile(filePath);
                if (null != amfFile.Error)
                {
                    ResultPath = filePath;
                    switch (amfFile.Error.Type)
                    {
                    case AmfFileError.Error.NoPermission:
                        Result = FileEnumerationResult.NoPermission;
                        break;

                    case AmfFileError.Error.Unreadable:
                        Result = FileEnumerationResult.Unreadable;
                        break;

                    default:
                        Result = FileEnumerationResult.Unknown;
                        break;
                    }
                }
                else
                {
                    dir.Files.Add(amfFile);
                    added = true;
                }
            }

            Logger.Trace(String.Format("AddFileToDirectory:End {0}", added));
            return(added);
        }
Beispiel #9
0
        static void BuildPpapiPath(string nameFormat, Environment.SpecialFolder appDataPath, string appPath, string appProfilePattern, string suffix, ref bool separatorBefore)
        {
            Logger.Trace(String.Format("BuildPpapiPath({0}, {1}, {2}, {3}, {4})", nameFormat, appDataPath, appPath, appProfilePattern, suffix));

            // …\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 (null == basePath)
                {
                    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>();
                foreach (var userDir in userDataDirectories)
                {
                    if (appProfileRegex.IsMatch(userDir))
                    {
                        path = Path.Combine(basePath, userDir);
                        if (Directory.Exists(path))
                        {
                            appProfilePaths.Add(path);
                        }
                    }
                }

                // Get shared object directories.
                var titsDirectories = new List <String>();
                foreach (var profilePath in appProfilePaths)
                {
                    // …\AppData\Local\Google\Chrome\User Data\{app_profile}
                    // …\AppData\Roaming\Opera Software\{app_profile}
                    path = profilePath;

                    // …\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}
                    foreach (var dir in flashProfilePaths)
                    {
                        path = Path.Combine(dir, suffix);
                        if (Directory.Exists(path))
                        {
                            titsDirectories.Add(path);
                        }
                    }
                }

                // Create items now that we know how many of them there are.
                int saveNum = 1;
                foreach (var titsDir in titsDirectories)
                {
                    var name  = String.Format(nameFormat, titsDirectories.Count > 1 ? String.Format(" #{0}", saveNum) : "");
                    var flash = new FlashDirectory(name, titsDir, separatorBefore, DirectoryKind.Regular);
                    separatorBefore = false;
                    _directories.Add(flash);
                    saveNum++;
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                ResultPath = path;

                if (ex is SecurityException ||
                    ex is UnauthorizedAccessException
                    )
                {
                    Result = FileEnumerationResult.NoPermission;
                }
                else if (ex is IOException)
                {
                    Result = FileEnumerationResult.Unreadable;
                }
                else
                {
                    Result = FileEnumerationResult.Unknown;
                }
            }
        }
Beispiel #10
0
        static void BuildNpapiPath(string nameFormat, string suffix, ref bool separatorBefore)
        {
            Logger.Trace(String.Format("BuildNpapiPath({0}, {1})", nameFormat, suffix));

            string path = "";

            try
            {
                // …\AppData\Roaming
                path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                if (null == path)
                {
                    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 titsDirectories = new List <String>();
                foreach (var flashProfile in flashProfilePaths)
                {
                    path = Path.Combine(flashProfile, suffix);
                    if (Directory.Exists(path))
                    {
                        titsDirectories.Add(path);
                    }
                }

                // Create items now that we know how many of them there are.
                int saveNum = 1;
                foreach (var titsDir in titsDirectories)
                {
                    path = titsDir;
                    var name  = String.Format(nameFormat, titsDirectories.Count > 1 ? String.Format(" #{0}", saveNum) : "");
                    var flash = new FlashDirectory(name, path, separatorBefore, DirectoryKind.Regular);
                    separatorBefore = false;
                    _directories.Add(flash);
                    saveNum++;
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                ResultPath = path;

                if (ex is SecurityException ||
                    ex is UnauthorizedAccessException
                    )
                {
                    Result = FileEnumerationResult.NoPermission;
                }
                else if (ex is IOException)
                {
                    Result = FileEnumerationResult.Unreadable;
                }
                else
                {
                    Result = FileEnumerationResult.Unknown;
                }
            }
        }
Beispiel #11
0
        static void BuildAIRPath(string nameFormat, ref bool separatorBefore)
        {
            Logger.Trace(String.Format("BuildAIRPath({0})", nameFormat));

            string path = "";

            try
            {
                // …\AppData\Roaming
                path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                if (null == path)
                {
                    return;
                }

                // ..\AppData\Roaming\com.taintedspace.t**s\Local Store\#SharedObjects
                path = Path.Combine(path, @"com.taintedspace.t**s\Local Store\#SharedObjects\");
                if (!Directory.Exists(path))
                {
                    return;
                }
                string parentPath = path;

                var dirs = new Dictionary <string, string>();
                dirs.Add("main", path);

                var airSaveSets = Directory.GetDirectories(path);
                foreach (var folder in airSaveSets)
                {
                    if (folder == parentPath)
                    {
                        continue;
                    }
                    path = folder;
                    var folderName = Path.GetFileName(folder);
                    dirs.Add(String.Format("Save Set {0}", folderName), folder);
                }

                // Create items now that we know how many of them there are.
                foreach (KeyValuePair <string, string> pair in dirs)
                {
                    var name = String.Format(nameFormat, pair.Key);
                    path = pair.Value;
                    var flash = new FlashDirectory(name, path, separatorBefore, DirectoryKind.Regular);
                    separatorBefore = false;
                    _directories.Add(flash);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                ResultPath = path;

                if (ex is SecurityException ||
                    ex is UnauthorizedAccessException
                    )
                {
                    Result = FileEnumerationResult.NoPermission;
                }
                else if (ex is IOException)
                {
                    Result = FileEnumerationResult.Unreadable;
                }
                else
                {
                    Result = FileEnumerationResult.Unknown;
                }
            }
        }
Beispiel #12
0
        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 titsDirectories = 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))
                        {
                            titsDirectories.Add(path);
                        }
                    }
                }

                // Create items now that we know how many of them there are.
                for (int i = 0; i < titsDirectories.Count; ++i)
                {
                    var name  = String.Format(nameFormat, titsDirectories.Count > 1 ? " #" + (i + 1) : "");
                    var flash = new FlashDirectory(name, titsDirectories[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;
            }
        }