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

SetUInt() public method

Sets the unsigned int.
public SetUInt ( uint offset, uint value ) : void
offset uint The offset.
value uint The value.
return void
        public void SetUInt(uint offset, uint value)
        {
            data[offset++] = (byte)(value & 0xFF);
            data[offset++] = (byte)((value >> 8) & 0xFF);
            data[offset++] = (byte)((value >> 16) & 0xFF);
            data[offset++] = (byte)((value >> 24) & 0xFF);
        }

Usage Example

        /// <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::SetUInt