예제 #1
0
        internal void SetDirectoryEntryMetadataValue(FatDirectoryEntryMetadata entryMetadata, string value)
        {
            if (IsRootDirectory())
            {
                throw new Exception("Root directory metadata can not be changed using the file stream.");
            }

            var data = ((FatDirectoryEntry)Parent).GetDirectoryEntryData();

            if (data.Length > 0)
            {
                var value2 = new byte[entryMetadata.DataLength];
                var value3 = Encoding.UTF8.GetBytes(value);
                for (var i = 0; i < value2.Length; i++)
                {
                    if (i < value3.Length)
                    {
                        value2[i] = value3[i];
                    }
                    else
                    {
                        value2[i] = 32;
                    }
                }
                var offset = EntryHeaderDataOffset + entryMetadata.DataOffset;
                Array.Copy(value2, 0, data, offset, entryMetadata.DataLength);
                ((FatDirectoryEntry)Parent).SetDirectoryEntryData(data);
            }
        }
예제 #2
0
        internal void SetLongFilenameEntryMetadataValue(uint entryHeaderDataOffset, FatDirectoryEntryMetadata entryMetadata, string value)
        {
            var data = GetDirectoryEntryData();

            if (data.Length > 0)
            {
                var value2 = Encoding.Unicode.GetBytes(value);
                var offset = entryHeaderDataOffset + entryMetadata.DataOffset;
                Array.Copy(value2, 0, data, (int)offset, (int)entryMetadata.DataLength);
                SetDirectoryEntryData(data);
            }
        }
예제 #3
0
        internal void SetLongFilenameEntryMetadataValue(uint entryHeaderDataOffset, FatDirectoryEntryMetadata entryMetadata, long value)
        {
            var data = GetDirectoryEntryData();

            if (data.Length > 0)
            {
                var value2 = new byte[entryMetadata.DataLength];
                value2.SetUInt32(0, (uint)value);
                var offset = entryHeaderDataOffset + entryMetadata.DataOffset;
                Array.Copy(value2, 0, data, (int)offset, (int)entryMetadata.DataLength);
                SetDirectoryEntryData(data);
            }
        }
예제 #4
0
        internal void SetDirectoryEntryMetadataValue(FatDirectoryEntryMetadata entryMetadata, byte value)
        {
            if (IsRootDirectory())
            {
                throw new Exception("Root directory metadata can not be changed using the file stream.");
            }

            var data = ((FatDirectoryEntry)Parent).GetDirectoryEntryData();

            if (data.Length > 0)
            {
                var offset = EntryHeaderDataOffset + entryMetadata.DataOffset;
                data[offset] = value;
                ((FatDirectoryEntry)Parent).SetDirectoryEntryData(data);
            }
        }
예제 #5
0
        internal void SetDirectoryEntryMetadataValue(FatDirectoryEntryMetadata entryMetadata, long value)
        {
            if (IsRootDirectory())
            {
                throw new Exception("Root directory metadata can not be changed using the file stream.");
            }

            var data = ((FatDirectoryEntry)Parent).GetDirectoryEntryData();

            if (data.Length > 0)
            {
                var value2 = new byte[entryMetadata.DataLength];
                value2.SetUInt32(0, (uint)value);
                var offset = EntryHeaderDataOffset + entryMetadata.DataOffset;
                Array.Copy(value2, 0, data, offset, entryMetadata.DataLength);
                ((FatDirectoryEntry)Parent).SetDirectoryEntryData(data);
            }
        }