Exemplo n.º 1
0
 /// <param name="fileNameNamespace">POSIX or Win32 or DOS, multiple flags are not supported</param>
 private FileNameRecord GetFileNameRecord(FileNameFlags fileNameNamespace)
 {
     foreach (AttributeRecord attribute in this.Attributes)
     {
         if (attribute is FileNameAttributeRecord)
         {
             FileNameRecord fileNameRecord = ((FileNameAttributeRecord)attribute).Record;
             if (fileNameRecord.IsInNamespace(fileNameNamespace))
             {
                 return(fileNameRecord);
             }
         }
     }
     return(null);
 }
Exemplo n.º 2
0
        public FileNameRecord(byte[] buffer, int offset)
        {
            ParentDirectory     = new MftSegmentReference(buffer, offset + 0x00);
            CreationTime        = StandardInformationRecord.ReadDateTime(buffer, offset + 0x08);
            ModificationTime    = StandardInformationRecord.ReadDateTime(buffer, offset + 0x10);
            MftModificationTime = StandardInformationRecord.ReadDateTime(buffer, offset + 0x18);
            LastAccessTime      = StandardInformationRecord.ReadDateTime(buffer, offset + 0x20);
            AllocatedLength     = LittleEndianConverter.ToUInt64(buffer, offset + 0x28);
            FileSize            = LittleEndianConverter.ToUInt64(buffer, offset + 0x30);
            FileAttributes      = (FileAttributes)LittleEndianConverter.ToUInt32(buffer, offset + 0x38);
            PackedEASize        = LittleEndianConverter.ToUInt16(buffer, offset + 0x3C);
            byte fileNameLength = ByteReader.ReadByte(buffer, offset + 0x40);

            Flags    = (FileNameFlags)ByteReader.ReadByte(buffer, offset + 0x41);
            FileName = Encoding.Unicode.GetString(buffer, offset + 0x42, fileNameLength * 2);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Function for adding elements to the string to build
 /// based on the flag values set
 /// </summary>
 /// <param name="flag">Flag to check</param>
 /// <param name="sep">Seperator to use, either -, . or Path.DirectorySeparatorChar</param>
 /// <param name="sb">Reference to the string builder object which will be modified</param>
 /// <param name="value">String to add to the string builder if the flag is set</param>
 /// <returns>true if sb was modified</returns>
 private bool AddFilenamePart(FileNameFlags flag,
                              char sep,
                              ref StringBuilder sb,
                              object value)
 {
     if (FileNameFlags.None != (flag & FileName))
     {
         if ('-' == sep || Path.DirectorySeparatorChar == sep)
         {
             sb.Append(sep);
         }
         sb.Append(value);
         return(true);
     }
     return(false);
 }
Exemplo n.º 4
0
        /// <param name="fileNameNamespace">POSIX or Win32 or DOS, multiple flags are not supported</param>
        public bool IsInNamespace(FileNameFlags fileNameNamespace)
        {
            bool isPosix = ((Flags & (FileNameFlags.Win32 | FileNameFlags.DOS)) == 0);

            return((fileNameNamespace == FileNameFlags.POSIX && isPosix) || (Flags & fileNameNamespace) != 0);
        }