Exemplo n.º 1
0
        public static bool Close()
        {
            if (View.disktool != null)
            {
                View.disktool.CloseDisk();
            }
            Model.Close();
            Publisher.Unregister("CD:ROOT");
            Publisher.Unregister("CD:PVD");
            RamDisk.Close();
            UndoRedo.Reset();
            pvd  = null;
            root = null;

            foreach (KeyValuePair <string, DirRec> pair in Records)
            {
                Publisher.Unregister(pair.Key);
            }
            Records.Clear();
            Path2Pos.Clear();
            Lba2Path.Clear();
            Logger.SetProgress(100);
            return(Logger.Pass("File closed"));
        }
Exemplo n.º 2
0
        public static bool Open(string path)
        {
            Logger.SetProgress(0);
            Close();
            if (!RamDisk.Open(path))
            {
                return(false);
            }

            if (!RamDisk.Read(0x10))
            {
                return(false);
            }

            RamDisk.map[0x11] = 0x6F;
            for (int i = 0; i < 0x10; i++)
            {
                RamDisk.map[i] = 0x6F;
            }

            Model.SetPos("CD:PVD", 0x10 * 2048);
            Model.SetLen("CD:PVD", 2048);
            pvd  = new VolDesc("CD:PVD", 0x10 * 2048);
            root = pvd.GetRootDir();
            Model.SetPos("CD:ROOT", root.LbaData * 2048);
            Model.SetLen("CD:ROOT", root.LenData);
            Model.SetRec("CD:ROOT", root);
            int lba = root.LbaData;
            int len = root.LenData;

            for (int i = 0; i < len; i++)
            {
                RamDisk.Read(lba + i);
            }
            int lenp = pvd.PathTableSize;
            int lba1 = pvd.LbaPathTable1;
            int lba2 = pvd.LbaPathTable2;

            for (int i = 0; i < lenp; i++)
            {
                RamDisk.Read(lba1 + i);
                RamDisk.Read(lba2 + i);
            }

            Records.Add("CD:ROOT", root);
            Path2Pos.Add("CD:ROOT", root.GetPos());
            Lba2Path.Add(lba, "CD:ROOT");
            Publisher.Register("CD:PVD", pvd);
            Publisher.Register("CD:ROOT", root);

            EnumDir("CD:ROOT", root, null);
            Model.Open();
            if (View.disktool != null)
            {
                View.disktool.OpenDisk();
            }

            string dir = AppDomain.CurrentDomain.BaseDirectory;

            File.WriteAllBytes(dir + "disk.map", RamDisk.map);

            Logger.SetProgress(100);
            return(Logger.Pass("File opened successfully " + path));
        }