public VolumePartition(PrimaryVolumeDescriptor pvd, PathTableRecords paths) { this.primary = pvd; this.paths = paths; terminator = new VolumeDescriptorSetTerminator(); }
private void FillDirFils(string iniPath, out PrimaryVolumeDescriptor pvd, out PathTableRecords paths) { sio.FileInfo fi; sio.StreamReader sr; PathTableRecord pth; List<string> files; string[] file; string[] sep; int sepPos; string str; int i, j; fi = new sio.FileInfo(iniPath + "partition.inf"); if (fi.Exists) sr = new sio.StreamReader(fi.FullName); else sr = new sio.StreamReader(new sio.MemoryStream(new byte[] { 0x0d, 0x0a, 0x0d, 0x0a, 0x0d, 0x0a, 0x0d, 0x0a, 0x0d, 0x0a, 0x0d, 0x0a })); pvd = new PrimaryVolumeDescriptor(); pvd.hdr2.sysId = misc.GetPadResChars(sr.ReadLine(), pvd.hdr2.sysId.Length); pvd.hdr2.volId = misc.GetPadResChars(sr.ReadLine(), pvd.hdr2.volId.Length); pvd.hdr3.volSetId = misc.GetPadResChars(sr.ReadLine(), pvd.hdr3.volSetId.Length); pvd.hdr3.publId = misc.GetPadResChars(sr.ReadLine(), pvd.hdr3.publId.Length); pvd.hdr3.prepId = misc.GetPadResChars(sr.ReadLine(), pvd.hdr3.prepId.Length); pvd.hdr3.appId = misc.GetPadResChars(sr.ReadLine(), pvd.hdr3.appId.Length); pvd.hdr3.copFileId = misc.GetPadResChars("", pvd.hdr3.copFileId.Length); pvd.hdr3.absFileId = misc.GetPadResChars("", pvd.hdr3.absFileId.Length); pvd.hdr3.bibFileId = misc.GetPadResChars("", pvd.hdr3.bibFileId.Length); files = new List<string>(); if (fi.Exists) { str = sr.ReadLine(); while (str != null) { if (str.Length > 0) files.Add(str); str = sr.ReadLine(); } } else { files.AddRange(sio.Directory.GetDirectories(iniPath, "*", sio.SearchOption.AllDirectories)); for (i = 0; i < files.Count; i++) files[i] += config.dirSep; files.AddRange(sio.Directory.GetFiles(iniPath, "*.*", sio.SearchOption.AllDirectories)); for (i = 0; i < files.Count; i++) files[i] = string.Format("0, 0, 0, {0}", files[i].Remove(0, iniPath.Length)); } sr.Close(); paths = new PathTableRecords(); paths.Add(new PathTableRecord("", false)); sep = new string[] { ", " }; for (i = 0; i < files.Count; i++) { file = files[i].Split(sep, StringSplitOptions.None); str = file[3]; if (str[str.Length - 1] == config.dirSep) if (sio.Directory.Exists(iniPath + str)) paths.Add(new PathTableRecord(str, Convert.ToBoolean(int.Parse(file[1])))); else throw new sio.DirectoryNotFoundException(string.Format("Directory '{0}' not found", iniPath + str)); } paths.SortDirs(); paths.SetParentDirNums(); for (i = 0; i < paths.Count; i++) { pth = paths[i]; pth.files = new FileRecords(); pth.files.Add(new FileDirectoryDescriptor("", true, 0, false, false)); for (j = i + 1; j < paths.Count; j++) if (paths[j].hdr.parDirNum == i) pth.files.Add(new FileDirectoryDescriptor(paths[j].fullName, true, 0, false, false)); } for (i = 0; i < files.Count; i++) { file = files[i].Split(sep, StringSplitOptions.None); str = file[3]; if (str[str.Length - 1] != config.dirSep) if (sio.File.Exists(iniPath + str)) { sepPos = str.LastIndexOf(config.dirSep) + 1; for (j = 0; j < paths.Count; j++) if (paths[j].fullName.Length == sepPos) if (str.IndexOf(paths[j].fullName) == 0) { paths[j].files.Add(new FileDirectoryDescriptor(str, false, i, Convert.ToBoolean(int.Parse(file[1])), Convert.ToBoolean(int.Parse(file[2])))); break; } if (j == paths.Count) throw new ArgumentException(string.Format("Parent directory not found for '{0}'", str)); } else throw new sio.FileNotFoundException(string.Format("File '{0}' not found", iniPath + str)); } }
public VolumePartition(sio.FileStream fs) { bool termFound; termFound = false; while (!termFound) { switch (fs.ReadByte()) { case 0: throw new NotImplementedException("Boot records are not supported"); case 1: primary = new PrimaryVolumeDescriptor(fs); break; case 2: throw new NotImplementedException("Supplementary descriptors are not supported"); case 3: partition = new VolumePartitionDescriptor(fs); break; case 255: terminator = new VolumeDescriptorSetTerminator(fs); termFound = true; break; default: throw new NotImplementedException(string.Format("{0:x}: descriptor is not supported", fs.Position - 1)); } } fs.Position = (long)primary.hdr3.locLTbl * ISO9660.logSize + ISO9660.fsOff; paths = new PathTableRecords(fs, primary.hdr3.pthTblSizeL); for (int i = 0; i < paths.Count; i++) { fs.Position = (long)paths[i].hdr.locExtent * ISO9660.logSize + ISO9660.fsOff; paths[i].files = new FileRecords(fs, paths[i].name, paths[i].fullName); } }