Esempio n. 1
0
 private void UnloadToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (fileLoaded)
     {
         lfiles = new List <LuaFile>();
         fs.Dispose();
         mfs.Dispose();
         disk.Dispose();
         m_luaFiles.Items.Clear();
         m_file.Text = "Project unloaded";
         Text        = "Dreamcaster";
         fileLoaded  = false;
     }
 }
Esempio n. 2
0
        public void Create()
        {
            var size = 1024 * 1024 * 1024; // 1gb


            var sectorSize       = 512;
            var headsPerCylinder = 16;
            var sectorsPerTrack  = 63;
            var cylinders        = size / (headsPerCylinder * sectorsPerTrack * sectorSize);

            var path = @"d:\temp\mbr.img";

            using var imgStream = File.Create(path);
            //var disk = Disk.Initialize(imgStream, Ownership.None, size, new Geometry(cylinders, headsPerCylinder, sectorsPerTrack, sectorSize));
            var disk = Disk.Initialize(imgStream, Ownership.None, size);

            BiosPartitionTable.Initialize(disk, WellKnownPartitionType.WindowsFat);

            // var bootSector = new byte[512];
            // imgStream.Position = 0;
            // imgStream.Read(bootSector, 0, bootSector.Length);
            // EndianUtilities.WriteBytesLittleEndian((ushort)sectorSize, bootSector, 11);
            // //EndianUtilities.ToUInt16LittleEndian(bpb, 11);
            // imgStream.Position = 0;
            // imgStream.Write(bootSector, 0, bootSector.Length);

            var partitionSize      = 1024 * 1024 * 512;
            var partitionCylinders = partitionSize / (headsPerCylinder * sectorsPerTrack * sectorSize);
            var partitionSectors   = partitionSize / sectorSize;

            // using FatFileSystem fs = FatFileSystem.FormatPartition(imgStream, "AmigaTest",
            //     new Geometry(partitionCylinders, headsPerCylinder, sectorsPerTrack, sectorSize), 1024 * 512,
            //     partitionSectors, 0);
            // fs.CreateDirectory(@"TestDir\CHILD");
            using FatFileSystem fs = FatFileSystem.FormatPartition(disk, 0, "AmigaMBRTest");

            var bootSector = new byte[512];

            imgStream.Position = 0;
            imgStream.Read(bootSector, 0, bootSector.Length);

            fs.CreateDirectory(@"TestDir\CHILD");

            using var s      = fs.OpenFile("foo.txt", FileMode.Create);
            using var writer = new StreamWriter(s, Encoding.UTF8);
            writer.WriteLine("hello");

            fs.Dispose();
            disk.Dispose();
        }