Mosa.ClassLib.BinaryFormat.SetByte C# (CSharp) Method

SetByte() public method

Sets the byte.
public SetByte ( uint offset, byte value ) : void
offset uint The offset.
value byte The value.
return void
        public void SetByte(uint offset, byte value)
        {
            data[offset] = value;
        }

Usage Example

示例#1
0
        /// <summary>
        /// Sets the name of the volume.
        /// </summary>
        /// <param name="volumeName">Name of the volume.</param>
        public void SetVolumeName(string volumeName)
        {
            if (volumeLabel.Length > 8)
                volumeLabel = volumeLabel.Substring(0, 8);

            FatFileLocation location = FindEntry(new Find.Volume(), 0);

            if (!location.Valid)
            {
                location = FindEntry(new Find.Empty(), 0);

                if (!location.Valid)
                    return; // TODO: something went wrong
            }

            BinaryFormat directory = new BinaryFormat(partition.ReadBlock(location.DirectorySector, 1));

            if (volumeName.Length > 8)
                volumeName = volumeName.Substring(0, 8);

            // Create Entry
            directory.SetString(Entry.DOSName + (location.DirectorySectorIndex * Entry.EntrySize), "            ", 11);
            directory.SetString(Entry.DOSName + (location.DirectorySectorIndex * Entry.EntrySize), volumeName);
            directory.SetByte(Entry.FileAttributes + (location.DirectorySectorIndex * Entry.EntrySize), (byte)FatFileAttributes.VolumeLabel);
            directory.SetByte(Entry.Reserved + (location.DirectorySectorIndex * Entry.EntrySize), 0);
            directory.SetByte(Entry.CreationTimeFine + (location.DirectorySectorIndex * Entry.EntrySize), 0);
            directory.SetUShort(Entry.CreationTime + (location.DirectorySectorIndex * Entry.EntrySize), 0);
            directory.SetUShort(Entry.CreationDate + (location.DirectorySectorIndex * Entry.EntrySize), 0);
            directory.SetUShort(Entry.LastAccessDate + (location.DirectorySectorIndex * Entry.EntrySize), 0);
            directory.SetUShort(Entry.LastModifiedTime + (location.DirectorySectorIndex * Entry.EntrySize), 0);
            directory.SetUShort(Entry.LastModifiedDate + (location.DirectorySectorIndex * Entry.EntrySize), 0);
            directory.SetUShort(Entry.FirstCluster + (location.DirectorySectorIndex * Entry.EntrySize), 0);
            directory.SetUInt(Entry.FileSize + (location.DirectorySectorIndex * Entry.EntrySize), 0);

            partition.WriteBlock(location.DirectorySector, 1, directory.Data);
        }
All Usage Examples Of Mosa.ClassLib.BinaryFormat::SetByte