Method used to wipe data.
Inheritance: ICloneable
コード例 #1
0
        public WipeMethod CreateMethod()
        {
            WipeMethod method = new WipeMethod();
            bool valid = false;
            int id = rand.Next();

            while(valid == false) {
                valid = true;

                for(int i = 0; i < wipeMethods.Count; i++) {
                    if(wipeMethods[i].Id == id) {
                        valid = false;
                        break;
                    }
                }

                id = rand.Next();
            }

            method.Id = id;
            wipeMethods.Add(method);
            return method;
        }
コード例 #2
0
        public bool SaveMethod(WipeMethod method)
        {
            Debug.AssertNotNull(method, "Method is null");
            string path = _folder;

            if(path[path.Length - 1] != '\\') {
                path += '\\';
            }

            path += method.Id.ToString() + ".sdm";
            return method.SaveNative(path);
        }
コード例 #3
0
        public bool ScanFolder()
        {
            Debug.AssertNotNull(_folder, "Folder not set");

            // get the files
            try {
                string[] files = Directory.GetFiles(_folder, "*" + MethodFileExtension, SearchOption.TopDirectoryOnly);

                if(files != null && files.Length > 0) {
                    for(int i = 0; i < files.Length; i++) {
                        WipeMethod method = new WipeMethod();

                        if(method.ReadNative(files[i]) == false) {
                            Debug.ReportWarning("Failed to load method. File: {0}", files[i]);
                        }
                        else {
                            // add to the category
                            wipeMethods.Add(method);
                        }
                    }
                }
            }
            catch(Exception e) {
                Debug.ReportError("Error while loading the methods. Folder: {0}, Exception: {1}", _folder, e.Message);
                return false;
            }

            return true;
        }
コード例 #4
0
        public bool RemoveMethod(WipeMethod method, bool removeFromDisk)
        {
            Debug.AssertNotNull(method, "Method is null");

            if(removeFromDisk) {
                try {
                    string path = Path.Combine(_folder, method.Id.ToString() + MethodFileExtension);

                    if(File.Exists(path)) {
                        File.Delete(path);
                    }
                    else {
                        Debug.ReportError("Method not found. File: {0}", path);
                    }
                }
                catch(Exception e) {
                    Debug.ReportError("Error while deleting method. Method ID: {0}, Folder: {1}, Exception: {2}", method.Id, _folder, e.Message);
                    return false;
                }
            }

            wipeMethods.Remove(method);
            return true;
        }
コード例 #5
0
ファイル: WipeMethod.cs プロジェクト: gratianlup/SecureDelete
        public object Clone()
        {
            WipeMethod temp = new WipeMethod();

            if(splitChars != null) {
                temp.splitChars = new char[splitChars.Length];
                splitChars.CopyTo(temp.splitChars, 0);
            }

            if(wipeSteps != null) {
                temp.wipeSteps = new List<WipeStepBase>(wipeSteps.Count);
                int count = wipeSteps.Count;

                for(int i = 0; i < count; i++) {
                    temp.wipeSteps.Add((WipeStepBase)wipeSteps[i].Clone());
                }

                temp.stepNumber = count;
            }
            else {
                temp.stepNumber = 0;
                temp.wipeSteps = new List<WipeStepBase>();
            }

            temp._id = _id;
            temp._name = _name;
            temp._description = _description;
            temp._author = _author;
            temp._checkWipe = _checkWipe;
            temp._shuffle = _shuffle;
            temp._shuffleFirst = _shuffleFirst;
            temp._shuffleLast = _shuffleLast;

            return temp;
        }
コード例 #6
0
        private void ShowMethodOptions(int index)
        {
            ShowOptionsPanel();
            activeMethod = (WipeMethod)_methodManager.Methods[index].Clone();
            activeMethodIndex = index;
            methodModified = false;

            MethodNameLabel.Text = activeMethod.Name + " method steps";
            MethodNameLabel2.Text = activeMethod.Name + " method settings";
            NameTextbox.Text = activeMethod.Name;
            ShuffleLastTextbox.Maximum = activeMethod.Steps.Count;
            CheckCheckbox.Checked = activeMethod.CheckWipe;

            PopulateStepList();
            ShuffleCheckbox.Checked = activeMethod.Shuffle;
            SetShuffleMinMax();

            if(ShuffleCheckbox.Checked) {
                ShuffleFirstTextbox.Value = activeMethod.ShuffleFirst + 1;
                ShuffleLastTextbox.Value = activeMethod.ShuffleLast + 1;
            }

            if(StepList.Items.Count > 0) {
                SelectStep(0, true);
            }

            methodModified = false;
            HandleMethodModified();
        }
コード例 #7
0
        private void SaveChages()
        {
            Debug.AssertNotNull(activeMethod, "ActiveMethod not set");

            if(methodModified == false) {
                HideOptionsPanel();
                return;
            }

            // validate
            if(activeMethod.ValidateMethod() == false) {
                MessageBox.Show("Wipe method not valid. Probably no wipe steps added.", "SecureDelete",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            _methodManager.Methods[activeMethodIndex] = activeMethod;
            activeMethod = (WipeMethod)activeMethod.Clone();
            _methodManager.SaveMethod(activeMethod);
            UpdateMethod(activeMethodIndex);

            methodModified = false;
            HandleMethodModified();
            HideOptionsPanel();
        }
コード例 #8
0
 private void AddWipeMethod()
 {
     activeMethod = _methodManager.CreateMethod();
     _methodManager.SaveMethod(activeMethod);
     activeMethodIndex = _methodManager.Methods.Count - 1;
     LoadMethods();
     MethodList.SelectedIndices.Add(activeMethodIndex);
     ShowMethodOptions(activeMethodIndex);
     UpdateMethodCountLabel();
 }