Пример #1
0
        public override List <LogicalEntity> GetFilesnames(int startCluster)
        {
            List <DirEntry>      dirEntries = new List <DirEntry>();
            List <LogicalEntity> names      = new List <LogicalEntity>();
            //try
            int numDirSectors = 0;
            int sector;

            if (startCluster == 0) // rootdir
            {
                sector        = ((_geometry.SectorsPerFAT * _geometry.NumberOfFATs) + _geometry.ReservedSectors);
                numDirSectors = (_geometry.MaxDirEntries * 32) / _geometry.BytesPerSector;
            }
            else
            {
                sector = _geometry.startDataSector + ((startCluster - 2) * _geometry.SectorsPerCluster);
            }
            bool done        = false;
            int  cluster     = startCluster;
            int  sectorCount = 0;

            while (!done)
            {
                byte[] data = readSector(sector);
                GetFilenames(data, dirEntries, ref done);
                GetNextSector(ref cluster, ref sector);
                sectorCount++;
                if ((numDirSectors > 0) && (sectorCount > numDirSectors))
                {
                    done = true;
                }
            }
            //catch
            {
            }
            foreach (DirEntry entry in dirEntries)
            {
                LogicalEntity entity = null;
                if ((entry.attributes & 0x10) != 0)
                {
                    entity = new LogicalDirectory();
                }
                else
                {
                    entity = new LogicalFile();
                }
                entity.diskImage = this;
                entity.name      = entry.filename;
                entity.data      = entry;
                names.Add(entity);
            }
            return(names);
        }
Пример #2
0
        private void HandleSetContent(String filename)
        {
            _inUse = true;
            DiskFactory.DiskType diskType = DiskFactory.DiskType.UNSPECIFIED;

            if (File.Exists(filename))
            {
                if (new FileInfo(filename).Length > 3000000)
                {
                    diskType = DiskFactory.DiskType.HD;
                }
            }
            _disk = DiskFactory.CreateDisk(filename, diskType);
            List <LogicalEntity> names = _disk.GetItems();

            DisplayItems(names);
            _titleBar.Text = Path.GetFileName(filename);
        }
Пример #3
0
        private void lstFiles_ItemActivate(object sender, EventArgs e)
        {
            ListView      view   = (ListView)sender;
            Object        tag    = view.FocusedItem.Tag;
            LogicalEntity entity = tag as LogicalEntity;

            if (entity != null)
            {
                List <LogicalEntity> items = entity.GetItems();
                DisplayItems(items);
            }


            //BasicReader br = new BasicReader();
//            DiskReader.FileContents contents = _reader.ReadFile(view.FocusedItem.Text);
            //string[] test = br.Translate(data);
            //new FileReader(test).ShowDialog();
        }