Beispiel #1
0
		/// <summary>
		/// Create directory in ISO file
		/// </summary>
		protected void MkDir(string path)
		{
			IsoFolder f = isoRoot;
			string[] ar = NormalizePath(path).Split('/');
			for (int i = 0; i < ar.Length; i++)
			{
				string key = ar[i].Trim().ToLower();
				if (!f.entries.ContainsKey(key))
				{
					var subf = new IsoFolder();
					subf.Name = ar[i].Trim();
					f.entries[key] = subf;
				}
				IsoEntry e = f.entries[key];
				if (e.IsFile)
				{
					//throw new Exception("cannot create directory \"" + ar[i].Trim() + "\", a file by that Name already exists");
					return; // already exists - silently fail for now
				}
				f = (IsoFolder)e;
			}
		}
Beispiel #2
0
		private void GenFiles(IsoFolder thisFolder)
		{
			foreach (KeyValuePair<string, IsoEntry> it in thisFolder.entries)
				if (it.Value.IsFile)
					GenFile((IsoFile)it.Value);
				else
					GenFiles((IsoFolder)it.Value);
		}
Beispiel #3
0
		private void GenPathTableEx(IsoFolder parentFolder, IsoFolder thisFolder, bool lsb)
		{
			var di = new FieldValidator(generator);

			// Path table record ( ECMA-119 section 9.4 )
			byte[] b_di = generator.IsoName(thisFolder.Name, true);
			di.Byte((byte)b_di.Length, 1);
			di.Byte(0, 2); // Extended Attribute Record Length
			if (lsb)
			{
				di.IntLSB(thisFolder.DataBlock, 3, 6); // Location of Extent
				di.ShortLSB(parentFolder.PathTableEntry, 7, 8); // Parent Directory Number
			}
			else
			{
				di.IntMSB(thisFolder.DataBlock, 3, 6); // Location of Extent
				di.ShortMSB(parentFolder.PathTableEntry, 7, 8); // Parent Directory Number
			}
			di.Bytes(b_di, 9, 8 + b_di.Length); // Directory Identifier
			if ((b_di.Length & 1) != 0)
				di.Byte(0, 9 + b_di.Length); // optional padding if LEN_DI is odd

			foreach (KeyValuePair<string, IsoEntry> it in thisFolder.entries)
				if (it.Value.IsFolder)
					GenPathTableEx(thisFolder, (IsoFolder)it.Value, lsb);
		}
Beispiel #4
0
		private void GenDirectoryTree(IsoFolder parent_folder, IsoFolder this_folder, byte root)
		{
			this_folder.PathTableEntry = NextPathTableEntry++;
			this_folder.DataBlock = generator.Index / LogicalBlockSize;
			DirectoryRecord(".", this_folder, root);
			DirectoryRecord("..", parent_folder, 0);

			foreach (KeyValuePair<string, IsoEntry> it in this_folder.entries)
				DirectoryRecord(it.Value.Name, it.Value, 0);

			this_folder.DataLength = generator.Index - this_folder.DataBlock * LogicalBlockSize;
			generator.FinishBlock();

			foreach (KeyValuePair<string, IsoEntry> it in this_folder.entries)
				if (it.Value.IsFolder)
					GenDirectoryTree(this_folder, (IsoFolder)it.Value, 0);
		}
Beispiel #5
0
		/// <summary>
		/// add a file to the ISO ( common implementation - called by AddFile() and AddBootFile() )
		/// </summary>
		private IsoFile AddFileEx(string path, FileInfo fileInfo)
		{
			string key;
			string[] ar = NormalizePath(path).Split('/');
			int i;
			IsoFolder f = isoRoot;
			for (i = 0; i < ar.Length - 1; i++)
			{
				key = ar[i].Trim().ToLower();
				if (!f.entries.ContainsKey(key))
				{
					var subf = new IsoFolder();
					subf.Name = ar[i].Trim();
					f.entries[key] = subf;
				}
				IsoEntry e = f.entries[key];
				if (e.IsFile)
				{
					throw new Exception("cannot create directory \"" + ar[i].Trim() + "\", a file by that Name already exists");

					//return;
				}
				f = (IsoFolder)e;
			}
			var x = new IsoFile(fileInfo);
			x.Name = ar[i].Trim();
			key = ar[i].Trim().ToLower();
			if (f.entries.ContainsKey(key))
			{
				//throw new Exception("file or folder by that Name already exists");
				return (IsoFile)f.entries[key]; // just don't add it for now...
			}
			f.entries[key] = x;

			return x;
		}