Esempio n. 1
0
        internal DirectoryEntry(byte[] bytes, ref int offset)
        {
            Attribute = (ATTR_FLAGS)bytes[0x0B + offset];

            #region LondName

            string longName = null;

            if (Attribute == ATTR_FLAGS.ATTR_LONG_NAME)
            {
                longName = GetLongName(bytes, ref offset).Split('\0')[0];
                Attribute = (ATTR_FLAGS)bytes[0x0B + offset];
            }

            LongName = longName;

            #endregion LongName

            #region Name

            string name = Encoding.ASCII.GetString(bytes, 0x00 + offset, 0x0B);

            if ((Attribute & ATTR_FLAGS.ATTR_VOLUME_ID) == ATTR_FLAGS.ATTR_VOLUME_ID)
            {
                Name = name;
            }
            else if ((Attribute & ATTR_FLAGS.ATTR_DIRECTORY) == ATTR_FLAGS.ATTR_DIRECTORY)
            {
                Name = name;
            }
            else
            {
                StringBuilder namesb = new StringBuilder();
                namesb.Append(name.Substring(0, 8).TrimEnd(' '));
                namesb.Append(".");
                namesb.Append(name.Substring(8, 3));
                Name = namesb.ToString();
            }

            #endregion Name

            CreateTime = GetFatDate(bytes, 0x10 + offset, 0x0E + offset, bytes[0x0D + offset], false);
            AccessTime = GetFatDate(bytes, 0x12 + offset, 0, 0, true);
            FirstClusterHigh = BitConverter.ToUInt16(bytes, 0x14 + offset);
            WriteTime = GetFatDate(bytes, 0x18 + offset, 0x16 + offset, 0, false);
            FirstClusterLow = BitConverter.ToUInt16(bytes, 0x1A + offset);
            FileSize = BitConverter.ToUInt32(bytes, 0x1C + offset);
            offset += 0x20;
        }
Esempio n. 2
0
        internal DirectoryEntry(byte[] bytes, ref int offset)
        {
            Attribute = (ATTR_FLAGS)bytes[0x0B + offset];

            #region LondName

            string longName = null;

            if (Attribute == ATTR_FLAGS.ATTR_LONG_NAME)
            {
                longName  = GetLongName(bytes, ref offset).Split('\0')[0];
                Attribute = (ATTR_FLAGS)bytes[0x0B + offset];
            }

            LongName = longName;

            #endregion LongName

            #region Name

            string name = Encoding.ASCII.GetString(bytes, 0x00 + offset, 0x0B);

            if ((Attribute & ATTR_FLAGS.ATTR_VOLUME_ID) == ATTR_FLAGS.ATTR_VOLUME_ID)
            {
                Name = name;
            }
            else if ((Attribute & ATTR_FLAGS.ATTR_DIRECTORY) == ATTR_FLAGS.ATTR_DIRECTORY)
            {
                Name = name;
            }
            else
            {
                StringBuilder namesb = new StringBuilder();
                namesb.Append(name.Substring(0, 8).TrimEnd(' '));
                namesb.Append(".");
                namesb.Append(name.Substring(8, 3));
                Name = namesb.ToString();
            }

            #endregion Name

            CreateTime       = GetFatDate(bytes, 0x10 + offset, 0x0E + offset, bytes[0x0D + offset], false);
            AccessTime       = GetFatDate(bytes, 0x12 + offset, 0, 0, true);
            FirstClusterHigh = BitConverter.ToUInt16(bytes, 0x14 + offset);
            WriteTime        = GetFatDate(bytes, 0x18 + offset, 0x16 + offset, 0, false);
            FirstClusterLow  = BitConverter.ToUInt16(bytes, 0x1A + offset);
            FileSize         = BitConverter.ToUInt32(bytes, 0x1C + offset);
            offset          += 0x20;
        }