Example #1
0
        public void AddFiles(Include save, DetectedLocationPathHolder location, Regex reg)
        {
            List <DetectedFile> files = new List <DetectedFile>();

            foreach (DetectedFile file in GatherFiles(save, location, reg))
            {
                if (!files.Contains(file))
                {
                    files.Add(file);
                }
            }

            foreach (Exclude exclude in save.Exclusions)
            {
                foreach (DetectedFile file in GatherFiles(exclude, location, new Regex(".*")))
                {
                    if (files.Contains(file))
                    {
                        files.Remove(file);
                    }
                }
            }

            foreach (DetectedFile file in files)
            {
                if (!this.Contains(file))
                {
                    this.AddRange(files);
                }
            }
        }
Example #2
0
 public void AddFiles(FileType type, DetectedLocationPathHolder location)
 {
     foreach (Include file in type.Inclusions)
     {
         AddFiles(file, location);
     }
 }
Example #3
0
        protected override void analyzerWork()
        {
            outputLine("Game Name: " + game.Title);

            this.path = game.DetectedLocations.getMostAccurateLocation();

            if (path.EV == EnvironmentVariable.VirtualStore) {
                string drive = Path.GetPathRoot(path.FullDirPath);
                string new_path = Path.Combine(drive, path.Path);
                this.path = Core.locations.interpretPath(new_path).getMostAccurateLocation();
            }

            string[] folders = this.path.Path.Split(System.IO.Path.DirectorySeparatorChar);

            string found_path = null;
            for (int i = folders.Length - 1; i >= 0; i--) {
                string temp_path = folders[0];
                for(int j = 1; j <= i; j++) {
                    temp_path = Path.Combine(temp_path,folders[j]);
                }

                DirectoryInfo dir = new DirectoryInfo(Path.Combine(path.AbsoluteRoot, temp_path));
                if (dir.GetFiles("*.exe").Length > 0) {
                    found_path = temp_path;
                    break;
                }

            }

            if (found_path != null) {
                path.ReplacePath(found_path);
            }

            outputLine("Operating System: ");
            outputLine(Environment.OSVersion.VersionString);

            ProgressHandler.max += 4;
            outputLine();
            outputLine("Path: ");
            outputPath(path.FullDirPath);
            outputLine();
            try {
                scanForScumm(path.FullDirPath);
            } catch (Exception ex) {
                outputLine("Error while attempting to cehck for ScummVM path entries:");
                recordException(ex);
            }
            try {
                TranslatingProgressHandler.setTranslatedMessage("DumpingFolder");
                ProgressHandler.value++;
                outputLine(Environment.NewLine + "Folder Dump: ");
                travelFolder(path.FullDirPath);
            } catch (Exception ex) {
                outputLine("Error while attempting to search the save folder:");
                recordException(ex);
            }
        }
Example #4
0
        public DetectedFile(DetectedLocationPathHolder location, string path, string name, string type)
            : base(location, location.FullDirPath, location.owner)
        {
            OriginalLocation = location;

            this.Path = path;
            this.Name = name;
            this.Type = type;
        }
 //protected DetectedLocations filterLocations(DetectedLocations locs, ScummVM scumm, string user) {
 //    List<string> keys = new List<string>(locs.Keys);
 //    foreach (string key in keys) {
 //        if (!filterLocation(locs[key], scumm, user)) {
 //            locs.Remove(key);
 //        }
 //    }
 //    return locs;
 //}
 protected bool filterLocation(DetectedLocationPathHolder loc, ScummVM scumm, string user)
 {
     DirectoryInfo dir = new DirectoryInfo(loc.FullDirPath);
     string pattern = scumm.Name + "*";
     if (dir.GetFiles(pattern).Length > 0) {
         loc.owner = user;
         return true;
     }
     return false;
 }
Example #6
0
        public MonitorPath(GameEntry game, DetectedLocationPathHolder path)
            : base(path.FullDirPath, "*")
        {
            this.Path = path;
            this.Game = game;

            this.IncludeSubdirectories = true;
            this.Created += new FileSystemEventHandler(changed);
            this.Changed += new FileSystemEventHandler(changed);
            this.Deleted += new FileSystemEventHandler(changed);
            this.Renamed += new RenamedEventHandler(changed);
        }
Example #7
0
        private static List <DetectedFile> GatherFiles(Exclude save, DetectedLocationPathHolder location, Regex reg)
        {
            List <DetectedFile> files = new List <DetectedFile>();

            foreach (string file in save.FindMatching(location.FullDirPath))
            {
                string name = Path.GetFileName(file);
                string path = file.Substring(0, file.Length - name.Length).Trim(Path.DirectorySeparatorChar);

                if (!reg.IsMatch(file))
                {
                    continue;
                }

                DetectedFile detected = new DetectedFile(location, path, name, save.Type);
                files.Add(detected);
            }
            return(files);
        }
Example #8
0
        protected override DetectedLocations getPaths(LocationPath get_me)
        {
            //if(get_me.rel_root!= EnvironmentVariable.Public)
            // return new List<DetectedLocationPathHolder>();
            DetectedLocations return_me = new DetectedLocations();
            DetectedLocationPathHolder add_me;
            DirectoryInfo test;
            switch (get_me.EV) {
                case EnvironmentVariable.InstallLocation:
                    LocationPath temp = new LocationPath(get_me);
                    string[] chopped = temp.Path.Split(Path.DirectorySeparatorChar);
                    for (int i = 0; i < chopped.Length; i++) {
                        temp.ReplacePath(chopped[i]);
                        for (int j = i + 1; j < chopped.Length; j++) {
                            temp.AppendPath(chopped[j]);
                        }
                        temp.EV = EnvironmentVariable.ProgramFiles;
                        return_me.AddRange(getPaths(temp));
                    }
                    return_me.AddRange(base.getPaths(get_me));
                    break;
                case EnvironmentVariable.ProgramFiles:
                case EnvironmentVariable.ProgramFilesX86:
                    // Always checks both the VirtualStore and the real Program Files,
                    // to make sure nothing is missed, especially in the case of old games
                    // that may or may not use the VirtualStore
                    if (!get_me.override_virtual_store && platform_version == "WindowsVista") {
                        LocationPath virtualstore_info = new LocationPath(get_me);
                        virtualstore_info.EV = EnvironmentVariable.LocalAppData;

                        if (x64) {
                            virtualstore_info.ReplacePath(Path.Combine("VirtualStore", global.getFolder(EnvironmentVariable.ProgramFilesX86).BaseFolder.Substring(3), virtualstore_info.Path));
                            return_me.AddRange(getPaths(virtualstore_info));
                            virtualstore_info = new LocationPath(get_me);
                            virtualstore_info.EV = EnvironmentVariable.LocalAppData;
                        }
                        virtualstore_info.ReplacePath(Path.Combine("VirtualStore", global.getFolder(EnvironmentVariable.ProgramFiles).BaseFolder.Substring(3), virtualstore_info.Path));
                        return_me.AddRange(getPaths(virtualstore_info));
                    }

                    if (x64) {
                        if (get_me.Path != null && get_me.Path.Length > 0)
                            test = new DirectoryInfo(Path.Combine(global.getFolder(EnvironmentVariable.ProgramFilesX86).BaseFolder, get_me.Path));
                        else
                            test = new DirectoryInfo(global.getFolder(EnvironmentVariable.ProgramFilesX86).BaseFolder);
                        if (test.Exists) {
                            add_me = new DetectedLocationPathHolder(get_me, global.getFolder(EnvironmentVariable.ProgramFilesX86).BaseFolder, null);
                            return_me.Add(add_me);
                        }
                    }

                    if (get_me.Path != null && get_me.Path.Length > 0)
                        test = new DirectoryInfo(Path.Combine(global.getFolder(EnvironmentVariable.ProgramFiles).BaseFolder, get_me.Path));
                    else
                        test = new DirectoryInfo(global.getFolder(EnvironmentVariable.ProgramFiles).BaseFolder);

                    if (test.Exists) {
                        add_me = new DetectedLocationPathHolder(get_me, global.getFolder(EnvironmentVariable.ProgramFiles).BaseFolder, null);
                        return_me.Add(add_me);
                    }
                    break;
                default:
                    return base.getPaths(get_me);
            }
            return return_me;
        }
 protected override DetectedLocations getPaths(LocationPath get_me)
 {
     DetectedLocations return_me = new DetectedLocations();
     DirectoryInfo test;
     DetectedLocationPathHolder add_me;
     switch (get_me.EV) {
         case EnvironmentVariable.InstallLocation:
             LocationPath temp = new LocationPath(get_me);
             string[] chopped = temp.Path.Split(Path.DirectorySeparatorChar);
             for (int i = 0; i < chopped.Length; i++) {
                 temp.ReplacePath(chopped[i]);
                 for (int j = i + 1; j < chopped.Length; j++) {
                     temp.AppendPath(chopped[j]);
                 }
                 temp.EV = EnvironmentVariable.Drive;
                 return_me.AddRange(getPaths(temp));
                 temp.EV = EnvironmentVariable.AltSavePaths;
                 return_me.AddRange(getPaths(temp));
             }
             break;
         case EnvironmentVariable.AltSavePaths:
             foreach (AltPathHolder alt_path in Core.settings.save_paths) {
                 if (PermissionsHelper.isReadable(alt_path.path)) {
                     if (get_me.Path != null && get_me.Path.Length > 0)
                         test = new DirectoryInfo(Path.Combine(alt_path.path, get_me.Path));
                     else
                         test = new DirectoryInfo(alt_path.path);
                     if (test.Exists) {
                         DetectedLocations locs = Core.locations.interpretPath(alt_path.path, get_me.Path);
                         foreach (DetectedLocationPathHolder loc in locs) {
                             return_me.Add(loc);
                         }
                     }
                 }
             }
             break;
         case EnvironmentVariable.Drive:
             foreach (string drive in drives) {
                 if (get_me.Path != null && get_me.Path.Length > 0)
                     test = new DirectoryInfo(Path.Combine(drive, get_me.Path));
                 else
                     test = new DirectoryInfo(drive);
                 if (test.Exists) {
                     add_me = new DetectedLocationPathHolder(get_me, drive, null);
                     return_me.Add(add_me);
                 }
             }
             break;
         default:
             return base.getPaths(get_me);
     }
     return return_me;
 }
Example #10
0
 protected override List<DetectedLocationPathHolder> getPaths(LocationPathHolder get_me)
 {
     List<DetectedLocationPathHolder> return_me = new List<DetectedLocationPathHolder>();
     DirectoryInfo test;
     DetectedLocationPathHolder add_me;
     switch(get_me.rel_root) {
         case EnvironmentVariable.InstallLocation:
             LocationPathHolder temp = new LocationPathHolder(get_me);
             string[] chopped = temp.path.Split(Path.DirectorySeparatorChar);
             for(int i = 0;i<chopped.Length;i++) {
                 temp.path = chopped[i];
                 for(int j=i+1;j<chopped.Length;j++) {
                     temp.path = Path.Combine(temp.path,chopped[j]);
                 }
                 temp.rel_root = EnvironmentVariable.Drive;
                 return_me.AddRange(getPaths(temp));
                 temp.rel_root = EnvironmentVariable.AltSavePaths;
                 return_me.AddRange(getPaths(temp));
             }
             break;
         case EnvironmentVariable.AltSavePaths:
             foreach(AltPathHolder alt_path in Core.settings.alt_paths) {
                 if(PermissionsHelper.isReadable(alt_path.path)) {
                     if(get_me.path!=null&&get_me.path.Length>0)
                         test = new DirectoryInfo(Path.Combine(alt_path.path, get_me.path));
                     else
                         test = new DirectoryInfo(alt_path.path);
                     if (test.Exists)  {
                         add_me  = new DetectedLocationPathHolder(get_me);
                         add_me.abs_root = alt_path.path;
                         return_me.Add(add_me);
                     }
                 }
             }
             break;
         case EnvironmentVariable.Drive:
             foreach(string drive in drives) {
                 if(get_me.path!=null&&get_me.path.Length>0)
                     test = new DirectoryInfo(Path.Combine(drive,get_me.path));
                 else
                     test = new DirectoryInfo(drive);
                 if(test.Exists) {
                     add_me  = new DetectedLocationPathHolder(get_me);
                     add_me.abs_root = drive;
                     return_me.Add(add_me);
                 }
             }
             break;
         default:
             return base.getPaths(get_me);
     }
     return return_me;
 }
Example #11
0
        protected override void doWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            base.doWork(sender, e);

            path_candidates = new SimpleModel<LocationPath>();
            user_candidates = new SimpleModel<string>();

            ProgressHandler.state = ProgressState.Indeterminate;
            try {
                if (archive == null) {
                }
            } catch (Exception ex) {
                TranslatingMessageHandler.SendException(ex);
            }

            if (ArgArchives.Count > 0)
                archive = new Archive(new FileInfo(ArgArchives.Dequeue()));

            if (archive == null)
                throw new TranslateableException("NoRestoreFileSelected");

            TranslatingProgressHandler.setTranslatedMessage("DetectingGameForRestoration");

            if (!archive.Exists)
                throw new TranslateableException("FileNotFound", archive.ArchivePath);

            GameID selected_game = archive.id.Game;
            string backup_owner = archive.id.Owner;
            string archive_type = archive.id.Type;

            try {
                game_data = Games.detectGame(selected_game);
            } catch (Exception ex) {
                TranslatingMessageHandler.SendException(ex);
            }

            NotifyPropertyChanged("GameNotDetected");

            if (game_data != null) {
                // This adds hypothetical locations
                foreach (LocationPath location in game_data.Locations.Paths) {
                    if (game_data.DetectionRequired)
                        break;

                    filterPathCandidates(location);
                }

                // This add already found locations
                foreach (DetectedLocationPathHolder location in game_data.DetectedLocations) {
                    location.IsSelected = true;
                    switch (location.EV) {
                        case EnvironmentVariable.ProgramFiles:
                        case EnvironmentVariable.ProgramFilesX86:
                            // This adds a fake VirtualStore folder, just in case
                            if (Core.locations.uac_enabled) {
                                DetectedLocationPathHolder temp = new DetectedLocationPathHolder(location, Core.locations.getFolder(EnvironmentVariable.LocalAppData, location.owner), location.owner);
                                temp.ReplacePath(Path.Combine("VirtualStore", location.FullDirPath.Substring(3)));
                                temp.EV = EnvironmentVariable.LocalAppData;
                                addPathCandidate(temp);
                            }
                            addPathCandidate(location);
                            break;
                        default:
                            addPathCandidate(location);
                            break;
                    }
                }

                //if (archive.id.Game.OS!=null&&archive.id.Game.OS.StartsWith("PS")) {

                //    foreach (string drive in Core.locations.ps.GetDriveCandidates()) {
                //        DetectedLocationPathHolder loc = new DetectedLocationPathHolder(EnvironmentVariable.Drive, drive, null);
                //            addPathCandidate(loc);
                //    }
                //}
            }

            if (archive.id.OriginalEV != EnvironmentVariable.None &&
                archive.id.OriginalRelativePath != null) {
                LocationPath path = new LocationPath(archive.id.OriginalEV, archive.id.OriginalRelativePath);
                filterPathCandidates(path);
            }

            if (archive.id.OriginalLocation != null) {
                DetectedLocations locs = Core.locations.interpretPath(archive.id.OriginalLocation);
                DetectedLocationPathHolder loc = locs.getMostAccurateLocation();
                if (loc != null) {
                    addPathCandidate(loc);
                }
            }

            if (path_candidates.Count == 1) {
                multiple_paths = false;
                NotifyPropertyChanged("only_path");
            } else if (path_candidates.Count > 1) {
                multiple_paths = true;
            } else {
                throw new TranslateableException("NoRestorePathsDetected", this.archive.id.ToString());
            }
        }
Example #12
0
 public void AddFiles(Include save, DetectedLocationPathHolder location)
 {
     AddFiles(save, location, new Regex(".*"));
 }