Ejemplo n.º 1
0
 public FileFAT(FileSystemFAT fileSystem, FolderFAT.DirectoryEntry entry, string path)
 {
     FileSystem   = fileSystem;
     Name         = PathUtils.MakeFileNameValid(entry.FileName);
     Path         = PathUtils.Combine(path, Name);
     _length      = entry.Length;
     Attributes   = new FileAttributesFAT(entry);
     FirstCluster = entry.ClusterNum;
     Deleted      = Attributes.Deleted;
 }
Ejemplo n.º 2
0
 public FolderFAT(FileSystemFAT fileSystem, long offset, long cluster)
 {
     _root        = true;
     Offset       = offset;
     FileSystem   = fileSystem;
     FirstCluster = cluster;
     Name         = GetVolumeName();
     Path         = FileSystem.Store.DeviceID;
     Loaded       = false;
     Attributes   = new FileAttributesFAT();
     Deleted      = Attributes.Deleted;
 }
Ejemplo n.º 3
0
 public FolderFAT(FileSystemFAT fileSystem, DirectoryEntry entry, string path)
 {
     _root        = false;
     FileSystem   = fileSystem;
     Offset       = entry.Offset;
     FirstCluster = entry.ClusterNum;
     Name         = PathUtils.MakeFileNameValid(entry.FileName);
     Path         = PathUtils.Combine(path, Name);
     Loaded       = false;
     Attributes   = new FileAttributesFAT(entry);
     Deleted      = Attributes.Deleted;
 }
Ejemplo n.º 4
0
        public FileFAT(FileSystemFAT fileSystem, long firstCluster)
        {
            FileSystem   = fileSystem;
            FirstCluster = firstCluster;
            Name         = Util.GetRandomString(8);
            Path         = PathUtils.Combine(FileSystem.Store.DeviceID, "?", Name);
            long currentCluster = FirstCluster;

            _length = 0;
            while (currentCluster >= 0)
            {
                // Note: This won't correctly calculate the length of a deleted file.
                currentCluster = FileSystem.GetNextCluster(currentCluster);
                _length       += FileSystem.BytesPerCluster;
            }
            Attributes = new FileAttributesFAT();
            Deleted    = true;
        }
Ejemplo n.º 5
0
            public DirectoryEntry(FileSystemFAT fileSystem, long offset)
            {
                byte[] data = fileSystem.Store.GetBytes((ulong)offset, DIR_ENTRY_SIZE);
                DIR_Name         = ASCIIEncoding.ASCII.GetString(data, 0, 11);
                DIR_Attr         = (FATDirectoryAttributes)data[11];
                DIR_NTRes        = data[12];
                DIR_CrtTimeTenth = data[13];
                DIR_CrtTime      = BitConverter.ToUInt16(data, 14);
                DIR_CrtDate      = BitConverter.ToUInt16(data, 16);
                DIR_LstAccDate   = BitConverter.ToUInt16(data, 18);
                DIR_FstClusHI    = BitConverter.ToUInt16(data, 20);
                DIR_WrtTime      = BitConverter.ToUInt16(data, 22);
                DIR_WrtDate      = BitConverter.ToUInt16(data, 24);
                DIR_FstClusLO    = BitConverter.ToUInt16(data, 26);
                DIR_FileSize     = BitConverter.ToUInt32(data, 28);

                Free = data[0] == 0x0 || data[0] == 0x05 || data[0] == 0xE5;
                Last = data[0] == 0x0;
                string filename = DIR_Name.Substring(0, 8).Trim().ToLower();
                string ext      = DIR_Name.Substring(8).Trim().ToLower();

                FileName = filename;
                if (ext != "")
                {
                    if ((Attributes & FATDirectoryAttributes.ATTR_VOLUME_ID) == 0)
                    {
                        FileName += ".";
                    }
                    FileName += ext;
                }
                Offset = fileSystem.GetDiskOffsetOfFATCluster(ClusterNum);

                if (LongNameEntry)
                {
                    LongName = string.Concat(Encoding.Unicode.GetString(data, 1, 10),
                                             Encoding.Unicode.GetString(data, 14, 12),
                                             Encoding.Unicode.GetString(data, 28, 4));
                }
            }