Пример #1
0
        private void GenPathTableEx(IsoFolder parentFolder, IsoFolder thisFolder, bool lsb)
        {
            var di = new FieldValidator(this.generator);

            // Path table record ( ECMA-119 section 9.4 )
            byte[] b_di = this.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);
                }
            }
        }
Пример #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);
         }
     }
 }
Пример #3
0
		/// <summary>
		/// create directory in ISO file
		/// </summary>
		public void MkDir(string path)
		{
			IsoFolder f = this.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;
			}
		}
Пример #4
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 = this.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);
        }
Пример #5
0
        /// <summary>
        /// create directory in ISO file
        /// </summary>
        public void MkDir(string path)
        {
            IsoFolder f = this.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;
            }
        }
Пример #6
0
        private void GenDirectoryTree(IsoFolder parent_folder, IsoFolder this_folder, byte root)
        {
            this_folder.PathTableEntry = NextPathTableEntry++;
            this_folder.DataBlock      = this.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 = this.generator.Index - this_folder.DataBlock * LogicalBlockSize;
            this.generator.FinishBlock();

            foreach (KeyValuePair <string, IsoEntry> it in this_folder.entries)
            {
                if (it.Value.IsFolder)
                {
                    GenDirectoryTree(this_folder, (IsoFolder)it.Value, 0);
                }
            }
        }
Пример #7
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);
		}
Пример #8
0
		private void GenDirectoryTree(IsoFolder parent_folder, IsoFolder this_folder, byte root)
		{
			this_folder.PathTableEntry = NextPathTableEntry++;
			this_folder.DataBlock = this.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 = this.generator.Index - this_folder.DataBlock * LogicalBlockSize;
			this.generator.FinishBlock();

			foreach (KeyValuePair<string, IsoEntry> it in this_folder.entries)
				if (it.Value.IsFolder)
					GenDirectoryTree(this_folder, (IsoFolder)it.Value, 0);
		}
Пример #9
0
		private void GenPathTableEx(IsoFolder parentFolder, IsoFolder thisFolder, bool lsb)
		{
			var di = new FieldValidator(this.generator);
			// Path table record ( ECMA-119 section 9.4 )
			byte[] b_di = this.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);
		}
Пример #10
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 = this.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;
		}