public void AddPath(RomPath path)
        {
            path.Id = currPathId;
            currPathId++;
            Paths.Add(path);

            isDirty = true;
        }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Rid"/> class.
 /// </summary>
 /// <param name="l">The l.</param>
 /// <param name="mf">The mf.</param>
 /// <param name="ffxipath">The ffxipath.</param>
 /// <param name="rm">The rm.</param>
 public Rid(Log l, HomeView mf, string ffxipath, RomPath rm)
 {
     Log          = l;
     Main         = mf;
     InstallPath  = ffxipath;
     RomPath      = rm;
     SubRegions   = new BindingList <SubRegion>();
     SrSubRegions = new List <SubRegion>();
 }
        public void AddRomPath(string Path, string AssociatedEmulator, string Extension)
        {
            RomPath newPath = new RomPath();
            newPath.FolderPath = Path;
            newPath.AssociatedEmulator = AssociatedEmulator;
            newPath.RomExtension = Extension;
            mLogger.Info(String.Format("Adding new rom path {0}", newPath.ToString()));

            mLoadedConfig.AddPath(newPath);

            onLoadedConfigChanged();
        }
예제 #4
0
 public PathTreeNode(string text, RomPath path)
 {
     Text = text;
     RomPath = path;
 }
예제 #5
0
        private string BuildFullGamePath(string GamesFolder, string GamePath)
        {
            string path = string.Empty;

            // check whether relative or absolute path has been set in the database for this game
            if (RomPath.StartsWith("."))
            {
                // path is relative (rom autoimported from defined path) - build path
                path = GamesFolder + GamePath;
            }
            else
            {
                // rom or disk has been manually added with full path - return just full path
                path = GamePath;
            }

            // now do 7zip processing if neccesary
            string extension = System.IO.Path.GetExtension(path).ToLower();

            if (extension == ".7z")
            {
                /* 7zip archive detected - extract contents to cache directory and modify path variable accordingly */

                // create cache directory if it does not exist
                string cacheDir = AppDomain.CurrentDomain.BaseDirectory + "Data\\Cache";
                Directory.CreateDirectory(cacheDir);

                // inspect the archive
                Archiving arch = new Archiving(path, SystemId);
                arch.ProcessArchive();

                // get filename
                string filename = arch.FileName;

                // get filesize
                long filesize = arch.FileSize;

                // check whether file already exists in cache
                string cacheFile = cacheDir + "\\" + filename;
                if (File.Exists(cacheFile))
                {
                    // file exists - check size
                    long length = new System.IO.FileInfo(cacheFile).Length;

                    if (length != filesize)
                    {
                        arch.ExtractArchive(cacheDir);
                    }
                }
                else
                {
                    // extract contents of archive to cache folder
                    arch.ExtractArchive(cacheDir);
                }

                // return the new path to the rom
                return(cacheFile);
            }

            return(path);
        }
예제 #6
0
        public string BuildFullGamePath(string GamesFolder, string GamePath)
        {
            string path      = string.Empty;
            string extension = string.Empty;

            // check whether relative or absolute path has been set in the database for this game
            if (RomPath.StartsWith("."))
            {
                // path is relative (rom autoimported from defined path) - build path
                path = GamesFolder + GamePath.TrimStart('.');
            }
            else
            {
                // rom or disk has been manually added with full path - return just full path
                path = GamePath;
            }

            // create cache directory if it does not exist
            string cacheDir = AppDomain.CurrentDomain.BaseDirectory + "Data\\Cache";

            Directory.CreateDirectory(cacheDir);

            /* now do archive processing */
            if (path.Contains("*/"))
            {
                // this is an archive file with a direct reference to a ROM inside
                string[] arr         = path.Split(new string[] { "*/" }, StringSplitOptions.None);
                string   archivePath = arr[0];
                string   archiveFile = arr[1];

                // copy specific rom from archive to cache folder and get cache rom path
                string cacheRom = Archive.ExtractFile(archivePath, archiveFile, cacheDir); //Archiving.SetupArchiveChild(archivePath, archiveFile, cacheDir);

                if (cacheRom != string.Empty)
                {
                    return(ParseSMD(cacheRom, cacheDir));
                }
            }
            else if (path.ToLower().Contains(".7z") || path.ToLower().Contains(".zip"))
            {
                // This is a standard archive with no defined link
                extension = System.IO.Path.GetExtension(path).ToLower();

                if (extension == ".zip") //zip
                {
                    // this should be a zip file with a single rom inside - pass directly to mednafen as is
                    using (System.IO.Compression.ZipArchive ar = System.IO.Compression.ZipFile.OpenRead(path))
                    {
                        foreach (System.IO.Compression.ZipArchiveEntry entry in ar.Entries)
                        {
                            if (entry.FullName.EndsWith(".smd", StringComparison.OrdinalIgnoreCase))
                            {
                                entry.Archive.ExtractToDirectory(cacheDir, true);
                                return(ParseSMD(Path.Combine(cacheDir, entry.FullName), cacheDir));
                            }
                        }
                    }

                    return(path);
                }

                else if (extension == ".7z")
                {
                    /* archive detected - extract contents to cache directory and modify path variable accordingly
                     * this is a legacy option really - in case people have a single rom in a .7z file in their library that
                     * has not been directly referenced in the gamepath */

                    // inspect the archive
                    Archive arch = new Archive(path);
                    var     res  = arch.ProcessArchive(null);

                    // iterate through
                    List <CompressionResult> resList = new List <CompressionResult>();
                    foreach (var v in res.Results)
                    {
                        if (GSystem.IsFileAllowed(v.RomName, SystemId))
                        {
                            resList.Add(v);
                        }
                    }

                    if (resList.Count == 0)
                    {
                        return(path);
                    }

                    // there should only be one result - take the first one
                    var resFinal = resList.FirstOrDefault();

                    // extract the rom to the cache
                    string cacheFile = Archive.ExtractFile(path, resFinal.InternalPath, cacheDir);

                    /*
                     * // check whether file already exists in cache
                     * string cacheFile = cacheDir + "\\" + resFinal.FileName;
                     * if (File.Exists(cacheFile))
                     * {
                     *  // file exists - check size
                     *  long length = new System.IO.FileInfo(cacheFile).Length;
                     *
                     *  if (length != filesize)
                     *  {
                     *      arch.ExtractArchive(cacheDir);
                     *  }
                     * }
                     * else
                     * {
                     *  // extract contents of archive to cache folder
                     *  arch.ExtractArchive(cacheDir);
                     * }
                     */

                    // return the new path to the rom
                    return(ParseSMD(cacheFile, cacheDir));
                }

                else if (extension == ".zip") //zip
                {
                    // this should be a zip file with a single rom inside - pass directly to mednafen as is (unless its an smd file)

                    using (System.IO.Compression.ZipArchive ar = System.IO.Compression.ZipFile.OpenRead(path))
                    {
                        foreach (System.IO.Compression.ZipArchiveEntry entry in ar.Entries)
                        {
                            if (entry.FullName.EndsWith(".smd", StringComparison.OrdinalIgnoreCase))
                            {
                                entry.Archive.ExtractToDirectory(cacheDir, true);
                                return(ParseSMD(Path.Combine(cacheDir, entry.FullName), cacheDir));
                            }
                        }
                    }

                    return(path);
                }
            }


            return(ParseSMD(path, cacheDir));
        }
예제 #7
0
        private void deletePath_Click(RomPath romPath, object p)
        {
            List<String> PathsThatWillBeDeleted = mPathResolver.ResolvePaths(romPath.FolderPath, romPath.RomExtension);
            String joinedPaths = String.Join("\n", PathsThatWillBeDeleted.ToArray());
            DialogResult res = MessageBox.Show(this, 
                                String.Format("WARNING: The following Roms will no longer be available to the emulator manager:\n{0}", joinedPaths), 
                                "CAUTION",
                                MessageBoxButtons.OKCancel);

            if(res == DialogResult.OK)
            {
                mLogger.Info(String.Format("Deleting path {0}", romPath.FolderPath));
                mConfigurationComponent.RemoveRomPath(romPath.Id);
            }
        }