Ejemplo n.º 1
0
        internal static NtfsFileEntry CreateEntry(NTFSWrapper ntfsWrapper, uint fileId, AttributeFileName fileName = null)
        {
            if (fileName == null)
            {
                // Dig up a preferred name
                FileRecord tmpRecord = ntfsWrapper.ReadMFTRecord(fileId);
                fileName = NtfsUtils.GetPreferredDisplayName(tmpRecord);
            }

            NtfsFileEntry entry = ntfsWrapper.FileCache.Get(fileId, fileName.FileName.GetHashCode());

            if (entry != null)
            {
                Debug.WriteLine("Got from cache: " + fileId + ":" + fileName.Id);
                return(entry);
            }

            // Create it
            FileRecord record = ntfsWrapper.ReadMFTRecord(fileId);

            if (record.Flags.HasFlag(FileEntryFlags.Directory))
            {
                entry = new NtfsDirectory(ntfsWrapper, record, fileName);
            }
            else
            {
                entry = new NtfsFile(ntfsWrapper, record, fileName);
            }

            ntfsWrapper.FileCache.Set(fileId, fileName.Id, entry);

            return(entry);
        }
Ejemplo n.º 2
0
        public void Set(uint id, ushort attributeId, NtfsFileEntry entry)
        {
            // Make combined key
            ulong key = CreateKey(id, attributeId);

            // Set
            _entries[key] = new WeakReference(entry);
        }