Example #1
0
 public DirectoryRecordWrapper(DirectoryRecord directoryRecord)
 {
     m_record = directoryRecord;
     m_date   = new DateWrapper(directoryRecord.Date);
 }
		private void SetDirectoryRecord( UInt32 extentLocation, UInt32 dataLength, DateTime date, sbyte timeZone, bool isDirectory, string name ) {
			m_date = new DateWrapper( date );
			byte fileFlags = ( isDirectory ) ? (byte)2 : (byte)0;

			byte[] fileIdentifier;
			if ( name == "." ) {
				fileIdentifier = new byte[1] { 0 };
			} else if ( name == ".." ) {
				fileIdentifier = new byte[1] { 1 };
			} else {
				if ( isDirectory ) {
					fileIdentifier = IsoAlgorithm.StringToByteArray( name );
				} else {
					fileIdentifier = IsoAlgorithm.StringToByteArray( name + ";1" );
				}
			}

			this.SetDirectoryRecord(
					IsoAlgorithm.BothEndian( extentLocation ),
					IsoAlgorithm.BothEndian( dataLength ),
					m_date.BinaryDateRecord,
					timeZone,
					fileFlags,
					fileIdentifier
			);
		}
		private void SetVolumeDescriptor( string systemId, string volumeId, UInt32 volumeSpaceSize, UInt32 pathTableSize,
										  UInt32 typeLPathTable, UInt32 typeMPathTable, DirectoryRecordWrapper rootDir, DateTime creationDate, DateTime modificationDate, sbyte timeZone ) {

			byte[] lSystemId;
			byte[] lVolumeId;

			if ( VolumeDescriptorType == VolumeType.Primary ) {

				lSystemId = IsoAlgorithm.StringToByteArray( systemId, IsoAlgorithm.SystemIdLength );
				lVolumeId = IsoAlgorithm.StringToByteArray( volumeId, IsoAlgorithm.VolumeIdLength );

			} else if ( VolumeDescriptorType == VolumeType.Suplementary ) {

				lSystemId = IsoAlgorithm.AsciiToUnicode( systemId, IsoAlgorithm.SystemIdLength );
				lVolumeId = IsoAlgorithm.AsciiToUnicode( volumeId, IsoAlgorithm.VolumeIdLength );

			} else {
				if ( m_volumeDescriptor == null ) {
					m_volumeDescriptor = new VolumeDescriptor();
				}
				m_volumeDescriptor.VolumeDescType = (byte)m_volumeDescriptorType;
				return;
			}

			UInt64 lVolumeSpaceSize = IsoAlgorithm.BothEndian( volumeSpaceSize );
			UInt64 lPathTableSize = IsoAlgorithm.BothEndian( pathTableSize );

			// typeLPathTable remains unchanged, but typeMPathTable has to change byte order.
			UInt32 lTypeMPathTable = IsoAlgorithm.ChangeEndian( typeMPathTable );
			DateWrapper lCreationDate = new DateWrapper( creationDate, timeZone );

			DateWrapper lModificationDate = new DateWrapper( modificationDate, timeZone );

			DateWrapper bufferDate = new DateWrapper( IsoAlgorithm.NoDate );

			this.SetVolumeDescriptor( lSystemId, lVolumeId, lVolumeSpaceSize, lPathTableSize, typeLPathTable, lTypeMPathTable,
									  rootDir.Record, lCreationDate.AsciiDateRecord, lModificationDate.AsciiDateRecord,
									  bufferDate.AsciiDateRecord, bufferDate.AsciiDateRecord );
		}
		public DirectoryRecordWrapper( DirectoryRecord directoryRecord ) {
			m_record = directoryRecord;
			m_date = new DateWrapper( directoryRecord.Date );
		}
		private void SetVolumeDescriptor( byte[] systemId, byte[] volumeId, UInt64 volumeSpaceSize, UInt64 pathTableSize,
										  UInt32 typeLPathTable, UInt32 typeMPathTable, DirectoryRecord rootDirRecord,
										  AsciiDateRecord creationDate, AsciiDateRecord modificationDate,
										  AsciiDateRecord expirationDate, AsciiDateRecord effectiveDate ) {

			if ( m_volumeDescriptor == null ) {
				m_volumeDescriptor = new VolumeDescriptor();
			}

			m_volumeDescriptor.VolumeDescType = (byte)m_volumeDescriptorType;

			systemId.CopyTo( m_volumeDescriptor.SystemId, 0 );
			volumeId.CopyTo( m_volumeDescriptor.VolumeId, 0 );
			m_volumeDescriptor.VolumeSpaceSize = volumeSpaceSize;
			m_volumeDescriptor.PathTableSize = pathTableSize;
			m_volumeDescriptor.TypeLPathTable = typeLPathTable;
			m_volumeDescriptor.TypeMPathTable = typeMPathTable;

			m_volumeDescriptor.RootDirRecord = rootDirRecord;
			m_rootDirRecord = new DirectoryRecordWrapper( rootDirRecord );

			m_volumeDescriptor.CreationDate = creationDate;
			m_creationDate = new DateWrapper( creationDate );

			m_volumeDescriptor.ModificationDate = modificationDate;
			m_modificationDate = new DateWrapper( modificationDate );

			m_volumeDescriptor.ExpirationDate = expirationDate;
			m_expirationDate = new DateWrapper( expirationDate );

			m_volumeDescriptor.EffectiveDate = effectiveDate;
			m_effectiveDate = new DateWrapper( effectiveDate );
		}