public void Exists() { CDBuilder builder = new CDBuilder(); builder.AddFile(@"dir\foo.txt", new byte[] { 1 }); CDReader fs = new CDReader(builder.Build(), false); Assert.IsFalse(fs.GetFileInfo("unknown.txt").Exists); Assert.IsTrue(fs.GetFileInfo(@"dir\foo.txt").Exists); Assert.IsFalse(fs.GetFileInfo(@"dir").Exists); }
public void Equals() { CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); Assert.AreEqual(fs.GetFileInfo("foo.txt"), fs.GetFileInfo("foo.txt")); }
public void BootImage() { byte[] memoryStream = new byte[33 * 512]; for (int i = 0; i < memoryStream.Length; ++i) { memoryStream[i] = (byte)i; } CDBuilder builder = new CDBuilder(); builder.SetBootImage(new MemoryStream(memoryStream), BootDeviceEmulation.HardDisk, 0x543); CDReader fs = new CDReader(builder.Build(), false); Assert.IsTrue(fs.HasBootImage); using (Stream bootImg = fs.OpenBootImage()) { Assert.AreEqual(memoryStream.Length, bootImg.Length); for (int i = 0; i < bootImg.Length; ++i) { if (memoryStream[i] != bootImg.ReadByte()) { Assert.Fail("Boot image corrupted"); } } } Assert.AreEqual(BootDeviceEmulation.HardDisk, fs.BootEmulation); Assert.AreEqual(0x543, fs.BootLoadSegment); }
public void FileSystemInfo() { CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); DiscFileSystemInfo fi = fs.GetFileSystemInfo(@"SOMEDIR\SOMEFILE"); Assert.IsNotNull(fi); }
public void CanWrite() { CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); Assert.IsFalse(fs.CanWrite); }
public void DirectoryInfo() { CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); DiscDirectoryInfo fi = fs.GetDirectoryInfo(@"SOMEDIR"); Assert.IsNotNull(fi); }
public void BootImage() { byte[] memoryStream = new byte[33 * 512]; for(int i = 0; i < memoryStream.Length; ++i) { memoryStream[i] = (byte)i; } CDBuilder builder = new CDBuilder(); builder.SetBootImage(new MemoryStream(memoryStream), BootDeviceEmulation.HardDisk, 0x543); CDReader fs = new CDReader(builder.Build(), false); Assert.IsTrue(fs.HasBootImage); using (Stream bootImg = fs.OpenBootImage()) { Assert.AreEqual(memoryStream.Length, bootImg.Length); for (int i = 0; i < bootImg.Length; ++i) { if (memoryStream[i] != bootImg.ReadByte()) { Assert.Fail("Boot image corrupted"); } } } Assert.AreEqual(BootDeviceEmulation.HardDisk, fs.BootEmulation); Assert.AreEqual(0x543, fs.BootLoadSegment); }
public void Parent_Root() { CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); Assert.IsNull(fs.Root.Parent); }
public void Equals() { CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); Assert.AreEqual(fs.GetFileInfo("foo.txt"), fs.GetFileInfo("foo.txt")); }
protected override void DoRun() { DirectoryInfo di = new DirectoryInfo(_srcDir.Value); if (!di.Exists) { Console.WriteLine("The source directory doesn't exist!"); Environment.Exit(1); } CDBuilder builder = new CDBuilder(); if (_volLabelSwitch.IsPresent) { builder.VolumeIdentifier = _volLabelSwitch.Value; } if (_bootImage.IsPresent) { builder.SetBootImage(new FileStream(_bootImage.Value, FileMode.Open, FileAccess.Read), BootDeviceEmulation.NoEmulation, 0); } PopulateFromFolder(builder, di, di.FullName); builder.Build(_isoFileParam.Value); }
public void GetDirectories() { CDBuilder builder = new CDBuilder(); builder.AddDirectory(@"SOMEDIR\CHILD\GCHILD"); builder.AddDirectory(@"A.DIR"); CDReader fs = new CDReader(builder.Build(), false); Assert.AreEqual(2, fs.Root.GetDirectories().Length); DiscDirectoryInfo someDir = fs.Root.GetDirectories(@"SoMeDir")[0]; Assert.AreEqual(1, fs.Root.GetDirectories("SOMEDIR").Length); Assert.AreEqual("SOMEDIR", someDir.Name); Assert.AreEqual(1, someDir.GetDirectories("*.*").Length); Assert.AreEqual("CHILD", someDir.GetDirectories("*.*")[0].Name); Assert.AreEqual(2, someDir.GetDirectories("*.*", SearchOption.AllDirectories).Length); Assert.AreEqual(4, fs.Root.GetDirectories("*.*", SearchOption.AllDirectories).Length); Assert.AreEqual(2, fs.Root.GetDirectories("*.*", SearchOption.TopDirectoryOnly).Length); Assert.AreEqual(1, fs.Root.GetDirectories("*.DIR", SearchOption.AllDirectories).Length); Assert.AreEqual(@"A.DIR\", fs.Root.GetDirectories("*.DIR", SearchOption.AllDirectories)[0].FullName); Assert.AreEqual(1, fs.Root.GetDirectories("GCHILD", SearchOption.AllDirectories).Length); Assert.AreEqual(@"SOMEDIR\CHILD\GCHILD\", fs.Root.GetDirectories("GCHILD", SearchOption.AllDirectories)[0].FullName); }
public void AddFileStream() { CDBuilder builder = new CDBuilder(); builder.AddFile(@"ADIR\AFILE.TXT", new MemoryStream()); CDReader fs = new CDReader(builder.Build(), false); Assert.IsTrue(fs.Exists(@"ADIR\AFILE.TXT")); }
public void Extension() { CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); Assert.AreEqual("dir", fs.GetDirectoryInfo("fred.dir").Extension); Assert.AreEqual("", fs.GetDirectoryInfo("fred").Extension); }
public void FileSystemInfo() { CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); DiscFileSystemInfo fi = fs.GetFileSystemInfo(@"SOMEDIR\SOMEFILE"); Assert.IsNotNull(fi); }
public void DirectoryInfo() { CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); DiscDirectoryInfo fi = fs.GetDirectoryInfo(@"SOMEDIR"); Assert.IsNotNull(fi); }
public void Extension() { CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); Assert.AreEqual("dir", fs.GetDirectoryInfo("fred.dir").Extension); Assert.AreEqual("", fs.GetDirectoryInfo("fred").Extension); }
public void AddFileBytes() { CDBuilder builder = new CDBuilder(); builder.AddFile(@"ADIR\AFILE.TXT", new byte[] {}); CDReader fs = new CDReader(builder.Build(), false); Assert.IsTrue(fs.Exists(@"ADIR\AFILE.TXT")); }
public void Open_FileNotFound() { CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); DiscFileInfo di = fs.GetFileInfo("foo.txt"); using (Stream s = di.Open(FileMode.Open)) { } }
public void CreationTimeUtc() { CDBuilder builder = new CDBuilder(); builder.AddFile(@"foo.txt", new byte[] { 1 }); CDReader fs = new CDReader(builder.Build(), false); Assert.GreaterOrEqual(DateTime.UtcNow, fs.GetFileInfo("foo.txt").CreationTimeUtc); Assert.LessOrEqual(DateTime.UtcNow.Subtract(TimeSpan.FromSeconds(10)), fs.GetFileInfo("foo.txt").CreationTimeUtc); }
public void Name() { CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); Assert.AreEqual("foo.txt", fs.GetFileInfo("foo.txt").Name); Assert.AreEqual("foo.txt", fs.GetFileInfo(@"path\foo.txt").Name); Assert.AreEqual("foo.txt", fs.GetFileInfo(@"\foo.txt").Name); }
public void Parent() { CDBuilder builder = new CDBuilder(); builder.AddDirectory(@"SOMEDIR"); CDReader fs = new CDReader(builder.Build(), false); Assert.AreEqual(fs.Root, fs.Root.GetDirectories("SOMEDIR")[0].Parent); }
public void FullName() { CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); Assert.AreEqual(@"\", fs.Root.FullName); Assert.AreEqual(@"SOMEDIR\", fs.GetDirectoryInfo(@"SOMEDIR").FullName); Assert.AreEqual(@"SOMEDIR\CHILDDIR\", fs.GetDirectoryInfo(@"SOMEDIR\CHILDDIR").FullName); }
public void AddFileBytes() { CDBuilder builder = new CDBuilder(); builder.AddFile(@"ADIR\AFILE.TXT", new byte[] {}); CDReader fs = new CDReader(builder.Build(), false); Assert.IsTrue(fs.Exists(@"ADIR\AFILE.TXT")); }
public void AddFileStream() { CDBuilder builder = new CDBuilder(); builder.AddFile(@"ADIR\AFILE.TXT", new MemoryStream()); CDReader fs = new CDReader(builder.Build(), false); Assert.IsTrue(fs.Exists(@"ADIR\AFILE.TXT")); }
public void Root() { CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); Assert.IsNotNull(fs.Root); Assert.IsTrue(fs.Root.Exists); Assert.IsEmpty(fs.Root.Name); Assert.IsNull(fs.Root.Parent); }
public void Exists() { CDBuilder builder = new CDBuilder(); builder.AddFile(@"dir\foo.txt", new byte[] { 1 }); CDReader fs = new CDReader(builder.Build(), false); Assert.IsFalse(fs.GetFileInfo("unknown.txt").Exists); Assert.IsTrue(fs.GetFileInfo(@"dir\foo.txt").Exists); Assert.IsFalse(fs.GetFileInfo(@"dir").Exists); }
public void CreationTimeUtc() { CDBuilder builder = new CDBuilder(); builder.AddFile(@"foo.txt", new byte[] { 1 }); CDReader fs = new CDReader(builder.Build(), false); Assert.GreaterOrEqual(DateTime.UtcNow, fs.GetFileInfo("foo.txt").CreationTimeUtc); Assert.LessOrEqual(DateTime.UtcNow.Subtract(TimeSpan.FromSeconds(10)), fs.GetFileInfo("foo.txt").CreationTimeUtc); }
public void SimpleSearch() { CDBuilder builder = new CDBuilder(); builder.AddFile(@"SOMEDIR\CHILDDIR\GCHILDIR\FILE.TXT", new byte[0]); CDReader fs = new CDReader(builder.Build(), false); DiscDirectoryInfo di = fs.GetDirectoryInfo(@"SOMEDIR\CHILDDIR"); DiscFileInfo[] fis = di.GetFiles("*.*", SearchOption.AllDirectories); }
public void Attributes() { CDBuilder builder = new CDBuilder(); builder.AddFile("foo.txt", new byte[] { 1 }); CDReader fs = new CDReader(builder.Build(), false); DiscFileInfo fi = fs.GetFileInfo("foo.txt"); // Check default attributes Assert.AreEqual(FileAttributes.ReadOnly, fi.Attributes); }
public void Parent() { CDBuilder builder = new CDBuilder(); builder.AddFile(@"SOMEDIR\ADIR\FILE.TXT", new byte[] { 1 }); CDReader fs = new CDReader(builder.Build(), false); DiscFileInfo fi = fs.GetFileInfo(@"SOMEDIR\ADIR\FILE.TXT"); Assert.AreEqual(fs.GetDirectoryInfo(@"SOMEDIR\ADIR"), fi.Parent); Assert.AreEqual(fs.GetDirectoryInfo(@"SOMEDIR\ADIR"), fi.Directory); }
public void Attributes() { CDBuilder builder = new CDBuilder(); builder.AddFile("foo.txt", new byte[] { 1 }); CDReader fs = new CDReader(builder.Build(), false); DiscFileInfo fi = fs.GetFileInfo("foo.txt"); // Check default attributes Assert.AreEqual(FileAttributes.ReadOnly, fi.Attributes); }
public void Exists() { CDBuilder builder = new CDBuilder(); builder.AddFile(@"SOMEDIR\CHILDDIR\FILE.TXT", new byte[0]); CDReader fs = new CDReader(builder.Build(), false); Assert.IsTrue(fs.GetDirectoryInfo(@"\").Exists); Assert.IsTrue(fs.GetDirectoryInfo(@"SOMEDIR").Exists); Assert.IsTrue(fs.GetDirectoryInfo(@"SOMEDIR\CHILDDIR").Exists); Assert.IsTrue(fs.GetDirectoryInfo(@"SOMEDIR\CHILDDIR\").Exists); Assert.IsFalse(fs.GetDirectoryInfo(@"NONDIR").Exists); Assert.IsFalse(fs.GetDirectoryInfo(@"SOMEDIR\NONDIR").Exists); }
public void BuildISO(Stream ISOOpen, string pathSave) { CDReader cd = new CDReader(ISOOpen, true); CDBuilder cb = new CDBuilder(); cb.UseJoliet = true; foreach (DiscFileInfo file in cd.Root.GetFiles("*.*", SearchOption.AllDirectories)) { foreach (DiscDirectoryInfo dir in cd.Root.GetDirectories("*.*", SearchOption.AllDirectories)) { cb.AddDirectory(dir.Name); cb.AddFile(file.FullName, cd.OpenFile(file.FullName, FileMode.Open)); } } cb.Build(pathSave); }
public void Exists() { CDBuilder builder = new CDBuilder(); builder.AddFile(@"SOMEDIR\CHILDDIR\FILE.TXT", new byte[0]); CDReader fs = new CDReader(builder.Build(), false); Assert.IsTrue(fs.GetDirectoryInfo(@"\").Exists); Assert.IsTrue(fs.GetDirectoryInfo(@"SOMEDIR").Exists); Assert.IsTrue(fs.GetDirectoryInfo(@"SOMEDIR\CHILDDIR").Exists); Assert.IsTrue(fs.GetDirectoryInfo(@"SOMEDIR\CHILDDIR\").Exists); Assert.IsFalse(fs.GetDirectoryInfo(@"NONDIR").Exists); Assert.IsFalse(fs.GetDirectoryInfo(@"SOMEDIR\NONDIR").Exists); }
public void LargeDirectory() { CDBuilder builder = new CDBuilder(); builder.UseJoliet = true; for (int i = 0; i < 3000; ++i) { builder.AddFile("FILE" + i + ".TXT", new byte[] { }); } CDReader reader = new CDReader(builder.Build(), true); Assert.AreEqual(3000, reader.Root.GetFiles().Length); }
public void Length() { CDBuilder builder = new CDBuilder(); builder.AddFile(@"FILE.TXT", new byte[0]); builder.AddFile(@"FILE2.TXT", new byte[1]); builder.AddFile(@"FILE3.TXT", new byte[10032]); builder.AddFile(@"FILE3.TXT;2", new byte[132]); CDReader fs = new CDReader(builder.Build(), false); Assert.AreEqual(0, fs.GetFileInfo("FILE.txt").Length); Assert.AreEqual(1, fs.GetFileInfo("FILE2.txt").Length); Assert.AreEqual(10032, fs.GetFileInfo("FILE3.txt;1").Length); Assert.AreEqual(132, fs.GetFileInfo("FILE3.txt;2").Length); Assert.AreEqual(132, fs.GetFileInfo("FILE3.txt").Length); }
public void Open_Read() { CDBuilder builder = new CDBuilder(); builder.AddFile("foo.txt", new byte[] { 1 }); CDReader fs = new CDReader(builder.Build(), false); DiscFileInfo di = fs.GetFileInfo("foo.txt"); using (Stream s = di.Open(FileMode.Open, FileAccess.Read)) { Assert.IsFalse(s.CanWrite); Assert.IsTrue(s.CanRead); Assert.AreEqual(1, s.ReadByte()); } }
public void HideVersions() { CDBuilder builder = new CDBuilder(); builder.UseJoliet = true; builder.AddFile("FILE.TXT;1", new byte[] { }); MemoryStream ms = new MemoryStream(); SparseStream.Pump(builder.Build(), ms); CDReader reader = new CDReader(ms, true, false); Assert.AreEqual("\\FILE.TXT;1", reader.GetFiles("")[0]); Assert.AreEqual("\\FILE.TXT;1", reader.GetFileSystemEntries("")[0]); reader = new CDReader(ms, true, true); Assert.AreEqual("\\FILE.TXT", reader.GetFiles("")[0]); Assert.AreEqual("\\FILE.TXT", reader.GetFileSystemEntries("")[0]); }
public void GetFileSystemInfos() { CDBuilder builder = new CDBuilder(); builder.AddDirectory(@"SOMEDIR\CHILD\GCHILD"); builder.AddDirectory(@"AAA.EXT"); builder.AddFile(@"FOO.TXT", new byte[10]); builder.AddFile(@"SOMEDIR\CHILD.TXT", new byte[10]); builder.AddFile(@"SOMEDIR\FOO.TXT", new byte[10]); builder.AddFile(@"SOMEDIR\CHILD\GCHILD\BAR.TXT", new byte[10]); CDReader fs = new CDReader(builder.Build(), false); Assert.AreEqual(3, fs.Root.GetFileSystemInfos().Length); Assert.AreEqual(1, fs.Root.GetFileSystemInfos("*.EXT").Length); Assert.AreEqual(2, fs.Root.GetFileSystemInfos("*.?XT").Length); }
public void RootBehaviour() { // Start time rounded down to whole seconds DateTime start = DateTime.UtcNow; start = new DateTime(start.Year, start.Month, start.Day, start.Hour, start.Minute, start.Second); CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); DateTime end = DateTime.UtcNow; Assert.AreEqual(FileAttributes.Directory | FileAttributes.ReadOnly, fs.Root.Attributes); Assert.GreaterOrEqual(fs.Root.CreationTimeUtc, start); Assert.LessOrEqual(fs.Root.CreationTimeUtc, end); Assert.GreaterOrEqual(fs.Root.LastAccessTimeUtc, start); Assert.LessOrEqual(fs.Root.LastAccessTimeUtc, end); Assert.GreaterOrEqual(fs.Root.LastWriteTimeUtc, start); Assert.LessOrEqual(fs.Root.LastWriteTimeUtc, end); }
public void HideVersions() { CDBuilder builder = new CDBuilder(); builder.UseJoliet = true; builder.AddFile("FILE.TXT;1", new byte[] { }); MemoryStream ms = new MemoryStream(); SparseStream.Pump(builder.Build(), ms); CDReader reader = new CDReader(ms, true, false); Assert.AreEqual("\\FILE.TXT;1", reader.GetFiles("")[0]); Assert.AreEqual("\\FILE.TXT;1", reader.GetFileSystemEntries("")[0]); reader = new CDReader(ms, true, true); Assert.AreEqual("\\FILE.TXT", reader.GetFiles("")[0]); Assert.AreEqual("\\FILE.TXT", reader.GetFileSystemEntries("")[0]); }
public void GetFiles() { CDBuilder builder = new CDBuilder(); builder.AddDirectory(@"SOMEDIR\CHILD\GCHILD"); builder.AddDirectory(@"AAA.DIR"); builder.AddFile(@"FOO.TXT", new byte[10]); builder.AddFile(@"SOMEDIR\CHILD.TXT", new byte[10]); builder.AddFile(@"SOMEDIR\FOO.TXT", new byte[10]); builder.AddFile(@"SOMEDIR\CHILD\GCHILD\BAR.TXT", new byte[10]); CDReader fs = new CDReader(builder.Build(), false); Assert.AreEqual(1, fs.Root.GetFiles().Length); Assert.AreEqual("FOO.TXT", fs.Root.GetFiles()[0].FullName); Assert.AreEqual(2, fs.Root.GetDirectories("SOMEDIR")[0].GetFiles("*.TXT").Length); Assert.AreEqual(4, fs.Root.GetFiles("*.TXT", SearchOption.AllDirectories).Length); Assert.AreEqual(0, fs.Root.GetFiles("*.DIR", SearchOption.AllDirectories).Length); }
public void Attributes() { // Start time rounded down to whole seconds DateTime start = DateTime.UtcNow; start = new DateTime(start.Year, start.Month, start.Day, start.Hour, start.Minute, start.Second); CDBuilder builder = new CDBuilder(); builder.AddDirectory("Foo"); CDReader fs = new CDReader(builder.Build(), false); DateTime end = DateTime.UtcNow; DiscDirectoryInfo di = fs.GetDirectoryInfo("Foo"); Assert.AreEqual(FileAttributes.Directory | FileAttributes.ReadOnly, di.Attributes); Assert.GreaterOrEqual(di.CreationTimeUtc, start); Assert.LessOrEqual(di.CreationTimeUtc, end); Assert.GreaterOrEqual(di.LastAccessTimeUtc, start); Assert.LessOrEqual(di.LastAccessTimeUtc, end); Assert.GreaterOrEqual(di.LastWriteTimeUtc, start); Assert.LessOrEqual(di.LastWriteTimeUtc, end); }
public void Attributes() { // Start time rounded down to whole seconds DateTime start = DateTime.UtcNow; start = new DateTime(start.Year, start.Month, start.Day, start.Hour, start.Minute, start.Second); CDBuilder builder = new CDBuilder(); builder.AddDirectory("Foo"); CDReader fs = new CDReader(builder.Build(), false); DateTime end = DateTime.UtcNow; DiscDirectoryInfo di = fs.GetDirectoryInfo("Foo"); Assert.AreEqual(FileAttributes.Directory | FileAttributes.ReadOnly, di.Attributes); Assert.GreaterOrEqual(di.CreationTimeUtc, start); Assert.LessOrEqual(di.CreationTimeUtc, end); Assert.GreaterOrEqual(di.LastAccessTimeUtc, start); Assert.LessOrEqual(di.LastAccessTimeUtc, end); Assert.GreaterOrEqual(di.LastWriteTimeUtc, start); Assert.LessOrEqual(di.LastWriteTimeUtc, end); }
public void Parent() { CDBuilder builder = new CDBuilder(); builder.AddFile(@"SOMEDIR\ADIR\FILE.TXT", new byte[] { 1 }); CDReader fs = new CDReader(builder.Build(), false); DiscFileInfo fi = fs.GetFileInfo(@"SOMEDIR\ADIR\FILE.TXT"); Assert.AreEqual(fs.GetDirectoryInfo(@"SOMEDIR\ADIR"), fi.Parent); Assert.AreEqual(fs.GetDirectoryInfo(@"SOMEDIR\ADIR"), fi.Directory); }
public void Length() { CDBuilder builder = new CDBuilder(); builder.AddFile(@"FILE.TXT", new byte[0]); builder.AddFile(@"FILE2.TXT", new byte[1]); builder.AddFile(@"FILE3.TXT", new byte[10032]); builder.AddFile(@"FILE3.TXT;2", new byte[132]); CDReader fs = new CDReader(builder.Build(), false); Assert.AreEqual(0, fs.GetFileInfo("FILE.txt").Length); Assert.AreEqual(1, fs.GetFileInfo("FILE2.txt").Length); Assert.AreEqual(10032, fs.GetFileInfo("FILE3.txt;1").Length); Assert.AreEqual(132, fs.GetFileInfo("FILE3.txt;2").Length); Assert.AreEqual(132, fs.GetFileInfo("FILE3.txt").Length); }
public List<DiscTrack> BuildGDROM(string data, string ipbin, List<string> cdda) { string bootBin; byte[] ipbinData = new byte[0x8000]; CDBuilder builder = new CDBuilder(); builder.VolumeIdentifier = VolumeIdentifier; builder.SystemIdentifier = SystemIdentifier; builder.VolumeSetIdentifier = VolumeSetIdentifier; builder.PublisherIdentifier = PublisherIdentifier; builder.DataPreparerIdentifier = DataPreparerIdentifier; builder.ApplicationIdentifier = ApplicationIdentifier; builder.UseJoliet = false; //A stupid default, mkisofs won't do this by default. builder.LBAoffset = GD_START_LBA; builder.EndSector = GD_END_LBA; using (FileStream ipfs = new FileStream(ipbin, FileMode.Open, FileAccess.Read, FileShare.Read)) { if (ipfs.Length != ipbinData.Length) { throw new Exception("IP.BIN is the wrong size. Possibly the wrong file? Cannot continue."); } bootBin = GetBootBin(ipfs); ipfs.Seek(0, SeekOrigin.Begin); ipfs.Read(ipbinData, 0, ipbinData.Length); } List<DiscTrack> retval = new List<DiscTrack>(); if (cdda != null && cdda.Count > 0) { retval = ReadCDDA(cdda); } DirectoryInfo di = new DirectoryInfo(data); PopulateFromFolder(builder, di, di.FullName, bootBin); using (BuiltStream isoStream = (BuiltStream)builder.Build()) { _lastProgress = 0; if (retval.Count > 0 || (TruncateData && !string.IsNullOrEmpty(LastTrackPath))) { if (RawMode) { ExportMultiTrackRaw(isoStream, ipbinData, retval); } else { ExportMultiTrack(isoStream, ipbinData, retval); } } else { if (RawMode) { ExportSingleTrackRaw(isoStream, ipbinData, retval); } else { ExportSingleTrack(isoStream, ipbinData, retval); } } } return retval; }
public void Name() { CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); Assert.AreEqual("foo.txt", fs.GetFileInfo("foo.txt").Name); Assert.AreEqual("foo.txt", fs.GetFileInfo(@"path\foo.txt").Name); Assert.AreEqual("foo.txt", fs.GetFileInfo(@"\foo.txt").Name); }
public void FullName() { CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); Assert.AreEqual(@"\", fs.Root.FullName); Assert.AreEqual(@"SOMEDIR\", fs.GetDirectoryInfo(@"SOMEDIR").FullName); Assert.AreEqual(@"SOMEDIR\CHILDDIR\", fs.GetDirectoryInfo(@"SOMEDIR\CHILDDIR").FullName); }
public void Open_Read() { CDBuilder builder = new CDBuilder(); builder.AddFile("foo.txt", new byte[] { 1 }); CDReader fs = new CDReader(builder.Build(), false); DiscFileInfo di = fs.GetFileInfo("foo.txt"); using (Stream s = di.Open(FileMode.Open, FileAccess.Read)) { Assert.IsFalse(s.CanWrite); Assert.IsTrue(s.CanRead); Assert.AreEqual(1, s.ReadByte()); } }
private string Run(int revision, string additionalFilePath, bool autoStartChecked) { string filename = string.Format("bootcd-{0}-dbg", revision); string filename7z = filename + ".7z"; string filenameIso = filename + ".iso"; if (!File.Exists(filenameIso)) { string filename7zTemp = filename7z + ".temp"; string filenameIsoTemp = filenameIso + ".temp"; if (!File.Exists(filename7z)) { File.Delete(filename7zTemp); WebClient wc = new WebClient(); try { wc.DownloadFile(revToUrl[revision], filename7zTemp); } catch (WebException) { return "File download failed:\n '" + revToUrl[revision] + "'"; } File.Move(filename7zTemp, filename7z); } File.Delete(filenameIsoTemp); FileStream isotmpfs = File.Create(filenameIsoTemp); FileStream szfs = File.Open(filename7z, FileMode.Open, FileAccess.Read); SevenZipExtractor sze = new SevenZipExtractor(szfs); sze.ExtractFile(filenameIso, isotmpfs); isotmpfs.Close(); szfs.Close(); File.Move(filenameIsoTemp, filenameIso); File.Delete(filename7z); } string vmName = string.Format("ReactOS_r{0}", revision); string diskName = Environment.CurrentDirectory + "\\" + vmName + "\\" + vmName + ".vdi"; if (File.Exists(diskName)) { FileStream fs = null; try { fs = File.Open(diskName, FileMode.Open, FileAccess.Read, FileShare.None); } catch (IOException) { return "Virtual machine '" + vmName + "' is already running"; } finally { if (fs != null) fs.Close(); } } string filenameIsoUnatt = filename + "_unatt.iso"; string filenameIsoUnattTemp = filenameIsoUnatt + ".temp"; File.Delete(filenameIsoUnattTemp); File.Delete(filenameIsoUnatt); FileStream isofs = File.Open(filenameIso, FileMode.Open, FileAccess.Read); CDReader cdr = new CDReader(isofs, true); CDBuilder cdb = new CDBuilder(); cdb.VolumeIdentifier = cdr.VolumeLabel; CloneCdDirectory("", cdr, cdb); if (!File.Exists("unattend.inf")) File.WriteAllText("unattend.inf", RosRegTest.Resources.unattend, Encoding.ASCII); string additionalFileName = null; if (additionalFilePath != null) additionalFileName = Path.GetFileName(additionalFilePath); string unattText = File.ReadAllText("unattend.inf", Encoding.ASCII); if (autoStartChecked && (additionalFileName != null)) unattText = unattText + "[GuiRunOnce]\n" + "cmd.exe /c start d:\\" + additionalFileName + "\n\n"; cdb.AddFile("reactos\\unattend.inf", Encoding.ASCII.GetBytes(unattText)); if (additionalFileName != null) cdb.AddFile(additionalFileName, additionalFilePath); Stream bootImgStr = cdr.OpenBootImage(); cdb.SetBootImage(bootImgStr, cdr.BootEmulation, cdr.BootLoadSegment); bootImgStr.Close(); cdb.Build(filenameIsoUnattTemp); isofs.Close(); File.Move(filenameIsoUnattTemp, filenameIsoUnatt); string fullIsoName = Environment.CurrentDirectory + "\\" + filenameIsoUnatt; string deleteVmCmd = string.Format("unregistervm --name {0}", vmName); string createVmCmd = string.Format( "createvm --name {0} --basefolder {1} --ostype WindowsXP --register", vmName, Environment.CurrentDirectory); string modifyVmCmd = string.Format("modifyvm {0} --memory 256 --vram 16 --nictype1 Am79C973 --audio none --boot1 disk --boot2 dvd", vmName); string storageCtlCmd = string.Format("storagectl {0} --name \"IDE Controller\" --add ide", vmName); string createMediumCmd = string.Format("createmedium disk --filename {0} --size 2048", diskName); string storageAttachCmd1 = string.Format("storageattach {0} --port 0 --device 0 --storagectl \"IDE Controller\" --type hdd --medium {1}", vmName, diskName); string storageAttachCmd2 = string.Format("storageattach {0} --port 1 --device 0 --storagectl \"IDE Controller\" --type dvddrive --medium {1}", vmName, fullIsoName); string startCmd = string.Format("startvm {0}", vmName); Exec(vboxManagePath, deleteVmCmd); Exec(vboxManagePath, createVmCmd); Exec(vboxManagePath, modifyVmCmd); Exec(vboxManagePath, storageCtlCmd); Exec(vboxManagePath, createMediumCmd); Exec(vboxManagePath, storageAttachCmd1); Exec(vboxManagePath, storageAttachCmd2); Exec(vboxManagePath, startCmd); return null; }
public void SimpleSearch() { CDBuilder builder = new CDBuilder(); builder.AddFile(@"SOMEDIR\CHILDDIR\GCHILDIR\FILE.TXT", new byte[0]); CDReader fs = new CDReader(builder.Build(), false); DiscDirectoryInfo di = fs.GetDirectoryInfo(@"SOMEDIR\CHILDDIR"); DiscFileInfo[] fis = di.GetFiles("*.*", SearchOption.AllDirectories); }
public void LargeDirectory() { CDBuilder builder = new CDBuilder(); builder.UseJoliet = true; for (int i = 0; i < 3000; ++i) { builder.AddFile("FILE" + i + ".TXT", new byte[] { }); } CDReader reader = new CDReader(builder.Build(), true); Assert.AreEqual(3000, reader.Root.GetFiles().Length); }
public void GetDirectories() { CDBuilder builder = new CDBuilder(); builder.AddDirectory(@"SOMEDIR\CHILD\GCHILD"); builder.AddDirectory(@"A.DIR"); CDReader fs = new CDReader(builder.Build(), false); Assert.AreEqual(2, fs.Root.GetDirectories().Length); DiscDirectoryInfo someDir = fs.Root.GetDirectories(@"SoMeDir")[0]; Assert.AreEqual(1, fs.Root.GetDirectories("SOMEDIR").Length); Assert.AreEqual("SOMEDIR", someDir.Name); Assert.AreEqual(1, someDir.GetDirectories("*.*").Length); Assert.AreEqual("CHILD", someDir.GetDirectories("*.*")[0].Name); Assert.AreEqual(2, someDir.GetDirectories("*.*", SearchOption.AllDirectories).Length); Assert.AreEqual(4, fs.Root.GetDirectories("*.*", SearchOption.AllDirectories).Length); Assert.AreEqual(2, fs.Root.GetDirectories("*.*", SearchOption.TopDirectoryOnly).Length); Assert.AreEqual(1, fs.Root.GetDirectories("*.DIR", SearchOption.AllDirectories).Length); Assert.AreEqual(@"A.DIR\", fs.Root.GetDirectories("*.DIR", SearchOption.AllDirectories)[0].FullName); Assert.AreEqual(1, fs.Root.GetDirectories("GCHILD", SearchOption.AllDirectories).Length); Assert.AreEqual(@"SOMEDIR\CHILD\GCHILD\", fs.Root.GetDirectories("GCHILD", SearchOption.AllDirectories)[0].FullName); }
public void Root() { CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); Assert.IsNotNull(fs.Root); Assert.IsTrue(fs.Root.Exists); Assert.IsEmpty(fs.Root.Name); Assert.IsNull(fs.Root.Parent); }
public override bool Execute() { Log.LogMessage(MessageImportance.Normal, "Creating ISO file: '{0}'", FileName.ItemSpec); try { CDBuilder builder = new CDBuilder(); builder.UseJoliet = UseJoliet; if (!string.IsNullOrEmpty(VolumeLabel)) { builder.VolumeIdentifier = VolumeLabel; } Stream bootImageStream = null; if (BootImage != null) { bootImageStream = new FileStream(BootImage.GetMetadata("FullPath"), FileMode.Open, FileAccess.Read); builder.SetBootImage(bootImageStream, BootDeviceEmulation.NoEmulation, 0); builder.UpdateIsolinuxBootTable = UpdateIsolinuxBootTable; } foreach (var sourceFile in SourceFiles) { builder.AddFile(GetDestinationPath(sourceFile), sourceFile.GetMetadata("FullPath")); } try { builder.Build(FileName.ItemSpec); } finally { if (bootImageStream != null) { bootImageStream.Dispose(); } } } catch(Exception e) { Log.LogErrorFromException(e, true, true, null); return false; } return !Log.HasLoggedErrors; }
public void Open_FileNotFound() { CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); DiscFileInfo di = fs.GetFileInfo("foo.txt"); using (Stream s = di.Open(FileMode.Open)) { } }
public void RootBehaviour() { // Start time rounded down to whole seconds DateTime start = DateTime.UtcNow; start = new DateTime(start.Year, start.Month, start.Day, start.Hour, start.Minute, start.Second); CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); DateTime end = DateTime.UtcNow; Assert.AreEqual(FileAttributes.Directory | FileAttributes.ReadOnly, fs.Root.Attributes); Assert.GreaterOrEqual(fs.Root.CreationTimeUtc, start); Assert.LessOrEqual(fs.Root.CreationTimeUtc, end); Assert.GreaterOrEqual(fs.Root.LastAccessTimeUtc, start); Assert.LessOrEqual(fs.Root.LastAccessTimeUtc, end); Assert.GreaterOrEqual(fs.Root.LastWriteTimeUtc, start); Assert.LessOrEqual(fs.Root.LastWriteTimeUtc, end); }
public void CanWrite() { CDBuilder builder = new CDBuilder(); CDReader fs = new CDReader(builder.Build(), false); Assert.IsFalse(fs.CanWrite); }