public static bool IsRomPack(Rom rom)
        {
            var ext = RomFunctions.GetFileExtension(rom.FileName).ToLower();

            if (ext == ".gdi" || ext == ".ccd" || ext == ".cue" || ext == ".rom")
            {
                FileInfo file = new FileInfo(rom.FileName);
                if (file.Directory.Name.ToLower() == rom.Name.ToLower())
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #2
0
        public static void CopyDBName(string dbName, bool keepSuffix, string oldRomName, string oldFileName, out string newRomName, out string newFileName)
        {
            newRomName  = "";
            newFileName = "";

            if (string.IsNullOrEmpty(dbName.Trim()))
            {
                return;
            }

            int bracketindex = oldFileName.IndexOf('[');
            int parindex     = oldFileName.IndexOf('(');
            int suffixIndex  = 0;

            if (bracketindex > -1 && parindex == -1)
            {
                suffixIndex = bracketindex;
            }
            else if (bracketindex == -1 && parindex > -1)
            {
                suffixIndex = parindex;
            }
            else if (bracketindex > -1 && parindex > -1)
            {
                suffixIndex = bracketindex > parindex ? parindex : bracketindex;
            }

            string suffix = suffixIndex == 0 ? string.Empty : RomFunctions.GetFileNameNoExtension(oldFileName).Substring(suffixIndex);

            if (keepSuffix)
            {
                newRomName  = dbName + " " + suffix;
                newFileName = dbName.Replace(":", " -") + " " + suffix;
            }
            else
            {
                newRomName  = dbName;
                newFileName = dbName.Replace(":", " -");
            }

            newFileName = newFileName + RomFunctions.GetFileExtension(oldFileName);

            newRomName  = newRomName.Trim();
            newFileName = newFileName.Trim();
        }
Beispiel #3
0
        private static bool RenameRomFileStandard(Rom rom, string changeFileName, bool changeZipFileName)
        {
            string oldFile = rom.Platform.DefaultRomPath + "\\" + rom.FileName;
            string newFile = rom.Platform.DefaultRomPath + "\\" + changeFileName;

            if (File.Exists(newFile))
            {
                throw new Exception("A file named \"" + newFile + "\" already exists!");
            }

            File.Move(oldFile, newFile);
            rom.FileName = changeFileName;

            if (changeZipFileName && RomFunctions.GetFileExtension(newFile) == ".zip")
            {
                RomFunctions.ChangeRomNameInsideZip(newFile);
            }

            return(true);
        }