コード例 #1
0
        private void SaveFileSystemImageToFile(FileSystemDrive fileSystemDrive, string path, string password)
        {
            var storageManagerProgress = new Progress <StorageManagerProgress>();

            LoadAndSaveProgressBar.Visible          = true;
            storageManagerProgress.ProgressChanged += (s, e) =>
            {
                LoadAndSaveProgressBar.Value      = e.ProgressPercentage;
                LoadAndSaveProgressInfoLabel.Text = e.Text;
            };

            saveAsToolStripMenuItem.Enabled = false;
            saveToolStripMenuItem.Enabled   = false;

            Task.Run(async() =>
            {
                var settings       = new StorageManagerSettings(true, Environment.ProcessorCount, true, password);
                var storageManager = new StorageManager(settings);

                bool success = await storageManager.SerializeObjectToFileAsync(fileSystemDrive, path, storageManagerProgress);

                OutcomeEventArgs outcomeEventArgs   = success ? OutcomeEventArgs.Success : OutcomeEventArgs.Failure;
                SaveFileEventHandler onSaveComplete = HandleSaveFileComplete;

                BeginInvoke(onSaveComplete, this, outcomeEventArgs);
            });
        }
コード例 #2
0
        public override bool TryParsePath(ISystemEntry root, string path, out ISystemEntry entry)
        {
            var filePath = new FilePath(path);
            entry = null;
            if (!filePath.IsValid) {
                return false;
            }

            // カレントディレクトリをベースに絶対パス変換
            if (filePath.IsRelative) {
                filePath = new FilePath(Environment.CurrentDirectory).Resolve(filePath);
            }

            if (!filePath.IsValid) {
                return false;
            }

            if (filePath.Fragments.Count == 0) {
                entry = new FileSystemDriveDirectory(root, "Drives");
                return true;
            } else {
                var drives = new FileSystemDriveDirectory(root, "Drives");
                var drive = new FileSystemDrive(drives, filePath.Fragments[0].ToUpper(), filePath.Fragments[0].ToUpper()[0]);

                IFileSystemEntry parent = drive;
                IFileSystemEntry subEntry = drive;
                foreach(var subPath in filePath.FragmentPaths.Skip(1)) {
                    subEntry = new FileSystemEntry(parent, subPath.FileName, subPath.FullPath);
                    parent = subEntry;
                }
                entry = subEntry;

                return true;
            }
        }
コード例 #3
0
        private void clearToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FolderTreeView.Nodes.Clear();
            FileListDataGridView.DataSource = null;
            _currentFileSystemDrive         = null;
            _currentFileName            = null;
            DirectoryInfoDataLabel.Text = "";

            MemoryHandler.RunGarbageCollect();
        }
コード例 #4
0
 //Forign thread
 public void SetFileSystemDrive(FileSystemDrive fileSystemDrive)
 {
     lock (this._fileSystemDriveLock)
     {
         this.currentFileSystemDrive = fileSystemDrive;
     }
     if (Visible)
     {
         Invoke(new CreateFileSystemImageComplete(this.SetFileSystemDriveComplete));
     }
     FileUtils.DeAllocateWorkerThread();
 }
コード例 #5
0
        private string GetRootDirectoryData(FileSystemDrive fileSystemDrive)
        {
            long directories   = 0;
            long files         = fileSystemDrive.RootFileList != null ? fileSystemDrive.RootFileList.Count : 0;
            long FileSizeTotal = fileSystemDrive.RootFileList != null?fileSystemDrive.RootFileList.Sum(f => f.FileSize) : 0;

            foreach (FileSystemDirectory fileSystemDirectory in fileSystemDrive.DirectoryList)
            {
                directories   += fileSystemDirectory.SubDirectoriesTotal + 1;
                files         += fileSystemDirectory.FilesTotal;
                FileSizeTotal += fileSystemDirectory.FileSizeTotal;
            }

            return("Directories: " + directories + " | Files: " + files + " | Total file size: " + GeneralConverters.FileSizeToStringFormater.ConvertFileSizeToString(FileSizeTotal, 2));
        }
コード例 #6
0
        private void openToolStripMenuItem_Click(object sender, EventArgs eventArgs)
        {
            var openFileDialog = new OpenFileDialog();
            var passwordDialog = new FormGetPassword();

            openFileDialog.Filter = "FileSystemImage files (*.fsi)|*.fsi";

            if (openFileDialog.ShowDialog() == DialogResult.OK && passwordDialog.ShowDialog(this) == DialogResult.OK)
            {
                string password = passwordDialog.PasswordString;
                _currentFileSystemDrive = null;
                _currentFileName        = openFileDialog.FileName;

                LoadAndSaveProgressInfoLabel.Text = "Opening file: " + openFileDialog.FileName;
                LoadFileSystemImageFromFile(_currentFileName, password);
                Log.Debug("Successfuly opened file: {FileName}", openFileDialog.FileName);
            }
        }
コード例 #7
0
        private void DoPartialTreeUpdateAsync(FileSystemDirectory targetDirectory)
        {
            var storageManagerProgress = new Progress <StorageManagerProgress>();

            LoadAndSaveProgressBar.Visible = true;
            openToolStripMenuItem.Enabled  = false;

            storageManagerProgress.ProgressChanged += (s, e) =>
            {
                LoadAndSaveProgressBar.Value      = e.ProgressPercentage;
                LoadAndSaveProgressInfoLabel.Text = e.Text;
            };

            Task.Run(async() =>
            {
                _currentFileSystemDrive = await FileUtils.UpdateFolderAsync(_currentFileSystemDrive, targetDirectory, storageManagerProgress);
                Invoke(new EventHandler(HandleOpenFileComplete));
            });
        }
コード例 #8
0
        public void LoadFileSystemDrive(FileSystemDrive fileSystemDrive)
        {
            _currentFileSystemDrive = fileSystemDrive;
            FolderTreeView.Nodes.Clear();

            if (_currentFileSystemDrive != null)
            {
                FolderTreeView.Nodes.Add(_currentFileSystemDrive.DriveLetter);
                TreeNode root = FolderTreeView.Nodes[0];
                root.ImageIndex         = 1;
                root.SelectedImageIndex = 1;
                root.StateImageIndex    = 1;
                root.Name = fileSystemDrive.DriveLetter;
                root.Tag  = new ROOT_Identifyer();

                foreach (FileSystemDirectory dir in _currentFileSystemDrive.DirectoryList)
                {
                    if (dir.DirectoryList == null)
                    {
                        root.Nodes.Add(dir.Name);
                    }
                    else
                    {
                        var treeNodeChildArr = new TreeNode[dir.DirectoryList.Count];
                        for (int i = 0; i < treeNodeChildArr.Length; i++)
                        {
                            treeNodeChildArr[i] = new TreeNode(dir.DirectoryList[i].Name);
                        }

                        root.Nodes.Add(new TreeNode(dir.Name, treeNodeChildArr));
                    }
                }
                if (fileSystemDrive.RootFileList != null)
                {
                    FileListDataGridView.DataSource = fileSystemDrive.RootFileList.ConvertAll(FileSystemFileWrapper.ConvertObject);
                }

                root.Expand();
            }
            MemoryHandler.RunGarbageCollect();
        }
コード例 #9
0
        private void LoadFileSystemImageFromFile(string path, string password)
        {
            var storageManagerProgress = new Progress <StorageManagerProgress>();

            LoadAndSaveProgressBar.Visible          = true;
            LoadAndSaveProgressInfoLabel.Visible    = true;
            openToolStripMenuItem.Enabled           = false;
            storageManagerProgress.ProgressChanged += (s, e) =>
            {
                LoadAndSaveProgressBar.Value      = e.ProgressPercentage;
                LoadAndSaveProgressInfoLabel.Text = e.Text;
            };
            Task.Run(async() =>
            {
                var settings       = new StorageManagerSettings(true, Environment.ProcessorCount, true, password);
                var storageManager = new StorageManager(settings);

                _currentFileSystemDrive = await storageManager.DeserializeObjectFromFileAsync <FileSystemDrive>(path, storageManagerProgress);
                Invoke(new EventHandler(HandleOpenFileComplete));
            });
        }
コード例 #10
0
        private static void AddToDb(string diskTitle, string rootPath)
        {
            IDiskDrive diskDrive = new FileSystemDrive(rootPath);

            Spelunker ddSpelunker = new Spelunker(diskDrive);

            ddSpelunker.SpelunkDd();

            using (var db = new SpelunkerContext())
            {
                if (!db.DiskDrives.Any(dd => dd.Title == diskTitle))
                {
                    db.Add(new DiskDrive {
                        Title = diskTitle
                    });
                    db.SaveChanges();

                    var disk = db.DiskDrives.First(dd => dd.Title == diskTitle);

                    foreach (var nugget in ddSpelunker.Nuggets)
                    {
                        disk.Files.Add(
                            new NuggetFile()
                        {
                            Title = nugget.Name,
                            Path  = nugget.Path
                        });
                    }

                    db.SaveChanges();
                }
                else
                {
                    Console.WriteLine("Disk already exists in DB");
                }
            }
        }
コード例 #11
0
        private static string MakeDriveLabel(FileSystemDrive drive)
        {
            string label = !string.IsNullOrEmpty(drive.Label) ? drive.Label : drive.GetTypeDescription();

            return($"{label} ({drive.Name})");
        }
コード例 #12
0
 public TreeSearch(FileSystemDrive fileSystemDrive)
 {
     _root = new FileSystemDirectory { DirectoryList = fileSystemDrive.DirectoryList, FileList = fileSystemDrive.RootFileList };
     _driveLetter = fileSystemDrive.DriveLetter.Replace("\\", "");
 }
コード例 #13
0
 public void SetFileSystemDrive(FileSystemDrive fileSystemDrive)
 {
     this.currentFileSystemDrive = fileSystemDrive;
 }
コード例 #14
0
 public DTOFileSystemDrive(FileSystemDrive fileSystemDrive)
 {
     Name  = fileSystemDrive.Name;
     Label = fileSystemDrive.Label;
     Type  = fileSystemDrive.Type;
 }
コード例 #15
0
 public void SetFileSystemDrive(FileSystemDrive fsd)
 {
     _fileSystemDrive = fsd;
 }