public IHawkFileArchiveHandler Construct(string path)
        {
            var ret = new SevenZipSharpArchiveHandler();

            ret.Open(path);
            return(ret);
        }
예제 #2
0
        public static BinaryStateLoader LoadAndDetect(string filename, bool isMovieLoad = false)
        {
            var ret = new BinaryStateLoader();

            // PORTABLE TODO - SKIP THIS.. FOR NOW
            // check whether its an archive before we try opening it
            bool isArchive;

            using (var archiveChecker = new SevenZipSharpArchiveHandler())
            {
                int  offset;
                bool isExecutable;
                isArchive = archiveChecker.CheckSignature(filename, out offset, out isExecutable);
            }

            if (!isArchive)
            {
                return(null);
            }

            try
            {
                ret._zip = new ZipFile(filename);
                ret.PopulateEntries();
                if (!isMovieLoad && !ret.GetLump(BinaryStateLump.Versiontag, false, ret.ReadVersion))
                {
                    ret._zip.Close();
                    return(null);
                }

                return(ret);
            }
            catch (ZipException)
            {
                return(null);
            }
        }
예제 #3
0
        public static BinaryStateLoader LoadAndDetect(string filename, bool isMovieLoad = false)
        {
            var ret = new BinaryStateLoader();

            // PORTABLE TODO - SKIP THIS.. FOR NOW
            // check whether its an archive before we try opening it
            bool isArchive;
            using (var archiveChecker = new SevenZipSharpArchiveHandler())
            {
                int offset;
                bool isExecutable;
                isArchive = archiveChecker.CheckSignature(filename, out offset, out isExecutable);
            }

            if (!isArchive)
            {
                return null;
            }

            try
            {
                ret._zip = new ZipFile(filename);
                ret.PopulateEntries();
                if (!isMovieLoad && !ret.GetLump(BinaryStateLump.Versiontag, false, ret.ReadVersion))
                {
                    ret._zip.Close();
                    return null;
                }

                return ret;
            }
            catch (ZipException)
            {
                return null;
            }
        }
		public IHawkFileArchiveHandler Construct(string path)
		{
			var ret = new SevenZipSharpArchiveHandler();
			ret.Open(path);
			return ret;
		}
예제 #5
0
        private void ProcessFileList(string[] fileList, ref Dictionary<LoadOrdering, List<FileInformation>> sortedFiles, string archive = null)
        {
            foreach (string file in fileList)
            {
                var ext = Path.GetExtension(file).ToUpper() ?? String.Empty;
                FileInformation fileInformation = new FileInformation(Path.GetDirectoryName(file), Path.GetFileName(file), archive);

                switch (ext)
                {
                    case ".LUA":
                        sortedFiles[LoadOrdering.LUASCRIPT].Add(fileInformation);
                        break;
                    case ".LUASES":
                        sortedFiles[LoadOrdering.LUASESSION].Add(fileInformation);
                        break;
                    case ".STATE":
                        sortedFiles[LoadOrdering.STATE].Add(fileInformation);
                        break;
                    case ".CHT":
                        sortedFiles[LoadOrdering.CHEAT].Add(fileInformation);
                        break;
                    case ".WCH":
                        sortedFiles[LoadOrdering.WATCH].Add(fileInformation);
                        break;
                    case ".CDL":
                        sortedFiles[LoadOrdering.CDLFILE].Add(fileInformation);
                        break;
                    default:
                        if (MovieService.IsValidMovieExtension(ext))
                            sortedFiles[LoadOrdering.MOVIEFILE].Add(fileInformation);
                        else if (MovieImport.IsValidMovieExtension(ext))
                            sortedFiles[LoadOrdering.LEGACYMOVIEFILE].Add(fileInformation);
                        else if (knownROMExtensions.Contains(ext))
                        {
                            if (String.IsNullOrEmpty(archive) || !nonArchive.Contains(ext))
                                sortedFiles[LoadOrdering.ROM].Add(fileInformation);
                        }
                        else
                        {
                            /* Because the existing behaviour for archives is to try loading
                             * ROMs out of them, that is exactly what we are going to continue
                             * to do at present.  Ideally, the archive should be scanned and
                             * relevant files should be extracted, but see the note below for
                             * further details.
                             */
                            int offset = 0;
                            bool executable = false;
                            var archiveHandler = new SevenZipSharpArchiveHandler();

                            if (String.IsNullOrEmpty(archive) && archiveHandler.CheckSignature(file, out offset, out executable))
                                sortedFiles[LoadOrdering.ROM].Add(fileInformation);

                            /*
                             * This is where handling archives would go.
                             * Right now, that's going to be a HUGE hassle, because of the problem with
                             * saving things into the archive (no) and with everything requiring filenames
                             * and not streams (also no), so for the purposes of making drag/drop more robust,
                             * I am not building this out just yet.
                             * -- Adam Michaud (Invariel)

                            int offset = 0;
                            bool executable = false;
                            var archiveHandler = new SevenZipSharpArchiveHandler();

                            // Not going to process nested archives at the moment.
                            if (String.IsNullOrEmpty (archive) && archiveHandler.CheckSignature(file, out offset, out executable))
                            {
                                List<string> fileNames = new List<string>();
                                var openedArchive = archiveHandler.Construct (file);

                                foreach (BizHawk.Common.HawkFileArchiveItem item in openedArchive.Scan ())
                                    fileNames.Add(item.Name);

                                ProcessFileList(fileNames.ToArray(), ref sortedFiles, file);

                                openedArchive.Dispose();
                            }
                            archiveHandler.Dispose();
                             */
                        }
                        break;
                }
            }
        }