public DateWrapper(AsciiDateRecord dateRecord) { AsciiDateRecord = dateRecord; byte year = (byte)(Convert.ToInt32(IsoAlgorithm.ByteArrayToString(dateRecord.Year)) - 1900); byte month = Convert.ToByte(IsoAlgorithm.ByteArrayToString(dateRecord.Month)); byte dayOfMonth = Convert.ToByte(IsoAlgorithm.ByteArrayToString(dateRecord.DayOfMonth)); byte hour = Convert.ToByte(IsoAlgorithm.ByteArrayToString(dateRecord.Hour)); byte minute = Convert.ToByte(IsoAlgorithm.ByteArrayToString(dateRecord.Minute)); byte second = Convert.ToByte(IsoAlgorithm.ByteArrayToString(dateRecord.Second)); int millisecond = Convert.ToInt32(IsoAlgorithm.ByteArrayToString(dateRecord.HundredthsOfSecond)) * 10; SetBinaryDateRecord(year, month, dayOfMonth, hour, minute, second); m_date = new DateTime(1900 + year, month, dayOfMonth, hour, minute, second, millisecond); }
private void SetVolumeDescriptor(string systemId, string volumeId, uint volumeSpaceSize, uint pathTableSize, uint typeLPathTable, uint 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; } ulong lVolumeSpaceSize = IsoAlgorithm.BothEndian(volumeSpaceSize); ulong lPathTableSize = IsoAlgorithm.BothEndian(pathTableSize); // typeLPathTable remains unchanged, but typeMPathTable has to change byte order. uint lTypeMPathTable = IsoAlgorithm.ChangeEndian(typeMPathTable); DateWrapper lCreationDate = new DateWrapper(creationDate, timeZone); DateWrapper lModificationDate = new DateWrapper(modificationDate, timeZone); DateWrapper bufferDate = new DateWrapper(IsoAlgorithm.NoDate); SetVolumeDescriptor(lSystemId, lVolumeId, lVolumeSpaceSize, lPathTableSize, typeLPathTable, lTypeMPathTable, rootDir.Record, lCreationDate.AsciiDateRecord, lModificationDate.AsciiDateRecord, bufferDate.AsciiDateRecord, bufferDate.AsciiDateRecord); }
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 ); }
public void SetPathTableRecord(uint extentLocation, ushort parentNumber, string name) { if (m_endian == Endian.BigEndian) { extentLocation = IsoAlgorithm.ChangeEndian(extentLocation); parentNumber = IsoAlgorithm.ChangeEndian(parentNumber); } byte[] identifier; if (name != ".") { identifier = IsoAlgorithm.StringToByteArray(name); } else { // If this is the root dir, then the identifier is 0. identifier = new byte[1] { 0 }; } SetPathTableRecord(extentLocation, parentNumber, identifier); }
private void SetAsciiDateRecord(int year, int month, int dayOfMonth, int hour, int minute, int second, int hundredthsOfSecond, sbyte timeZone) { if (AsciiDateRecord == null) { AsciiDateRecord = new AsciiDateRecord(); } string sYear = string.Format("{0:D4}", year % 10000); string sMonth = string.Format("{0:D2}", month); string sDay = string.Format("{0:D2}", dayOfMonth); string sHour = string.Format("{0:D2}", hour); string sMinute = string.Format("{0:D2}", minute); string sSecond = string.Format("{0:D2}", second); string sHundredths = string.Format("{0:D2}", hundredthsOfSecond); AsciiDateRecord.Year = IsoAlgorithm.StringToByteArray(sYear); AsciiDateRecord.Month = IsoAlgorithm.StringToByteArray(sMonth); AsciiDateRecord.DayOfMonth = IsoAlgorithm.StringToByteArray(sDay); AsciiDateRecord.Hour = IsoAlgorithm.StringToByteArray(sHour); AsciiDateRecord.Minute = IsoAlgorithm.StringToByteArray(sMinute); AsciiDateRecord.Second = IsoAlgorithm.StringToByteArray(sSecond); AsciiDateRecord.HundredthsOfSecond = IsoAlgorithm.StringToByteArray(sHundredths); AsciiDateRecord.TimeZone = timeZone; }