public override void RemoveFile(File _file) { if (_file == null) { return; } //Clear selection ClearSelection(); //Get index of cluster to remove var listIndex = GetIndexFragmentClusterFileOfFile(_file); //Clear cluster foreach (var index in listIndex) { Clusters.ElementAt(index).Content = new EmptyContentCluster(); } Files.Remove(_file); SelectedFile = null; var needUpdate = RootDirectory.NeedUpdateRootDirectory(); if (needUpdate) { DeleteRootDirectory(); } }
public void DecreaseClusterFile(int _oldSize, File _file) { //New number cluster var nCluster = (int)Math.Ceiling((decimal)_file.Size / Settings.Settings.ClusterSize); //Number clear cluster var numberClusterToDelete = _file.NumberClusterUse - nCluster; //Get index of cluster to remove var listIndex = (List <int>)GetIndexFragmentClusterFileOfFile(_file); //Clear clusters for (var i = 0; i < numberClusterToDelete; i++) { var cluster = Clusters.ElementAt(listIndex.Last()); cluster.ClusterFile = new EmptyClusterFile(); listIndex.RemoveAt(listIndex.Count - 1); } if (listIndex.Count > 0) { //Update cluster var cluster = Clusters.ElementAt(listIndex.Last()); if (cluster.ClusterFile is FragmentClusterFile fragmentFile) { fragmentFile.NextCluster = null; } } }
public void DeleteFile(File _file) { //Clear selection SelectionClear(); //Get index of cluster to remove var listIndex = GetIndexFragmentClusterFileOfFile(_file); //Clear cluster foreach (var index in listIndex) { Clusters.ElementAt(index).ClusterFile = new EmptyClusterFile(); } }
private void Initialize() { // init reserved cluster (1er and 2nd) Clusters.ElementAt(0).Content = new ReservedContentCluster(); Clusters.ElementAt(1).Content = new ReservedContentCluster(); // init root directory var cluster = Clusters.ElementAt(2); var rootDirectorsCluster = cluster; rootDirectorsCluster.Content = new RootDirectoryContentCluster(); RootDirectory.CurrentCluster = cluster; // init commands DeleteAllFileCommand = new RelayCommand(_param => RemoveAllFiles(), _param => true); DeleteFileCommand = new RelayCommand(_param => RemoveFile(SelectedFile), _param => SelectedFile != null); ModifyFileCommand = new RelayCommand(_param => ModifySelectedFile(), _param => SelectedFile != null); NewFileCommand = new RelayCommand(_param => NewFile(), _param => true); }