Esempio n. 1
0
        internal DirectoryEntry AddEntry(File file, string name, FileNameNamespace nameNamespace)
        {
            if (name.Length > 255)
            {
                throw new IOException("Invalid file name, more than 255 characters: " + name);
            }
            else if (name.IndexOfAny(new char[] { '\0', '/' }) != -1)
            {
                throw new IOException(@"Invalid file name, contains '\0' or '/': " + name);
            }

            FileNameRecord newNameRecord = file.GetFileNameRecord(null, true);

            newNameRecord.FileNameNamespace = nameNamespace;
            newNameRecord.FileName          = name;
            newNameRecord.ParentDirectory   = MftReference;

            NtfsStream nameStream = file.CreateStream(AttributeType.FileName, null);

            nameStream.SetContent(newNameRecord);

            file.HardLinkCount++;
            file.UpdateRecordInMft();

            Index[newNameRecord] = file.MftReference;

            Modified();
            UpdateRecordInMft();

            return(new DirectoryEntry(this, file.MftReference, newNameRecord));
        }
Esempio n. 2
0
        public string GetFirstName(FileRecordReference dir, FileNameNamespace aliasNamespace)
        {
            foreach (StructuredNtfsAttribute <FileNameRecord> attr in GetAttributes(AttributeType.FileName))
            {
                FileNameRecord fnr = attr.Content;
                if (fnr.ParentDirectory.Equals(dir) && fnr.FileNameNamespace == aliasNamespace)
                {
                    return(fnr.FileName);
                }
            }

            return(null);
        }
 public FileNameRecord(FileNameRecord toCopy)
 {
     ParentDirectory         = toCopy.ParentDirectory;
     CreationTime            = toCopy.CreationTime;
     ModificationTime        = toCopy.ModificationTime;
     MftChangedTime          = toCopy.MftChangedTime;
     LastAccessTime          = toCopy.LastAccessTime;
     AllocatedSize           = toCopy.AllocatedSize;
     RealSize                = toCopy.RealSize;
     Flags                   = toCopy.Flags;
     EASizeOrReparsePointTag = toCopy.EASizeOrReparsePointTag;
     FileNameNamespace       = toCopy.FileNameNamespace;
     FileName                = toCopy.FileName;
 }
        public int ReadFrom(byte[] buffer, int offset)
        {
            ParentDirectory         = new FileRecordReference(Utilities.ToUInt64LittleEndian(buffer, offset + 0x00));
            CreationTime            = ReadDateTime(buffer, offset + 0x08);
            ModificationTime        = ReadDateTime(buffer, offset + 0x10);
            MftChangedTime          = ReadDateTime(buffer, offset + 0x18);
            LastAccessTime          = ReadDateTime(buffer, offset + 0x20);
            AllocatedSize           = Utilities.ToUInt64LittleEndian(buffer, offset + 0x28);
            RealSize                = Utilities.ToUInt64LittleEndian(buffer, offset + 0x30);
            Flags                   = (FileAttributeFlags)Utilities.ToUInt32LittleEndian(buffer, offset + 0x38);
            EASizeOrReparsePointTag = Utilities.ToUInt32LittleEndian(buffer, offset + 0x3C);
            byte fnLen = buffer[offset + 0x40];

            FileNameNamespace = (FileNameNamespace)buffer[offset + 0x41];
            FileName          = Encoding.Unicode.GetString(buffer, offset + 0x42, fnLen * 2);

            return(0x42 + (fnLen * 2));
        }
Esempio n. 5
0
        public string GetFirstName(FileRecordReference dir, FileNameNamespace aliasNamespace)
        {
            foreach (StructuredNtfsAttribute<FileNameRecord> attr in GetAttributes(AttributeType.FileName))
            {
                FileNameRecord fnr = attr.Content;
                if (fnr.ParentDirectory.Equals(dir) && fnr.FileNameNamespace == aliasNamespace)
                {
                    return fnr.FileName;
                }
            }

            return null;
        }