static void Main(string[] args) { var options = new Options(); if (!Parser.Default.ParseArguments(args, options)) { return; } //tools var dd = @"Tools\dd.exe"; var grub = @"Tools\boot\"; var myos = @"Tools\myos.img"; var grubstage1 = @"Tools\boot\stage1"; //stuff we need var img = options.OutPutFile; var folder = options.inputfolder; //create file // StartProcces(dd, "bs=512 if=" + grubstage1 + " of=" + img + "count=2880", ""); File.Copy(myos, img); using (FileStream fs = File.Open(img, FileMode.Open)) { using (FatFileSystem floppy = new FatFileSystem(fs)) { foreach (var i in Directory.GetFiles(folder)) { using (Stream s = floppy.OpenFile(new FileInfo(i).Name, FileMode.Create)) { var x = File.ReadAllBytes(i); s.Write(x, 0, x.Length); } } } } //dd if=./Bin/boot.bin of=./Bin/bootimage.ima }
public void HonoursReadOnly() { SparseMemoryStream diskStream = new SparseMemoryStream(); FatFileSystem fs = FatFileSystem.FormatFloppy(diskStream, FloppyDiskType.HighDensity, "FLOPPY_IMG "); fs.CreateDirectory(@"AAA"); fs.CreateDirectory(@"BAR"); using (Stream t = fs.OpenFile(@"BAR\AAA.TXT", FileMode.Create, FileAccess.ReadWrite)) { } using (Stream s = fs.OpenFile(@"BAR\FOO.TXT", FileMode.Create, FileAccess.ReadWrite)) { StreamWriter w = new StreamWriter(s); w.WriteLine("FOO - some sample text"); w.Flush(); } fs.SetLastAccessTimeUtc(@"BAR", new DateTime(1980, 1, 1)); fs.SetLastAccessTimeUtc(@"BAR\FOO.TXT", new DateTime(1980, 1, 1)); // Check we can access a file without any errors SparseStream roDiskStream = SparseStream.ReadOnly(diskStream, Ownership.None); FatFileSystem fatFs = new FatFileSystem(roDiskStream); using (Stream fileStream = fatFs.OpenFile(@"BAR\FOO.TXT", FileMode.Open)) { fileStream.ReadByte(); } }