Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
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;
        }
Exemplo n.º 3
0
        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(test.FullName);
                            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);
        }
Exemplo n.º 4
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);
        }