Example #1
0
        private unsafe void StatusDialog_Load(object sender, EventArgs e)
        {
            // read data from file mapping
            long handle;
            string[] args = Environment.GetCommandLineArgs();

            if(args.Length < 2) {
                this.Close();
            }

            if(long.TryParse(args[1], out handle) == false) {
                this.Close();
            }

            IntPtr view = MapViewOfFile((IntPtr)handle, SECTION_MAP_READ, 0, 0, IntPtr.Zero);
            SDHeader header;
            int position = 0;

            // error
            if(view == IntPtr.Zero) {
                this.Close();
                return;
            }

            try {
                header = (SDHeader)Marshal.PtrToStructure(view, typeof(SDHeader));
                operationType = header.OperationType;
                position += header.Size;

                // move operation, get drop folder
                if(operationType == MOVE_OPERATION) {
                    moveFolder = header.data1;
                }

                // get wipe objects
                for(int i = 0; i < header.ObjectCount; i++) {
                    string path;
                    SDObject obj = (SDObject)Marshal.PtrToStructure((IntPtr)(view.ToInt64() + position), typeof(SDObject));
                    path = Marshal.PtrToStringUni((IntPtr)(view.ToInt64() + position + obj.PathOffset));
                    position += obj.Size;

                    if(obj.ObjectType == OBJECT_TYPE_FILE) {
                        FileWipeObject file = new FileWipeObject();
                        file.Path = path;
                        file.WipeMethodId = WipeOptions.DefaultWipeMethod;

                        // add to wipe list
                        session.Items.Add(file);

                        if(operationType == MOVE_OPERATION) {
                            // add to copy list
                            FileCopyItem item = FileCopyItem.MoveToFolder(path, moveFolder);

                            if(item != null) {
                                fileCopy.Items.Add(item);
                            }
                        }
                    }
                    else if(obj.ObjectType == OBJECT_TYPE_FOLDER) {
                        FolderWipeObject folder = new FolderWipeObject();
                        folder.Path = path;
                        folder.DeleteFolders = true;
                        folder.WipeSubfolders = true;
                        folder.UseMask = false;
                        folder.UseRegex = false;
                        folder.WipeMethodId = WipeOptions.DefaultWipeMethod;
                        session.Items.Add(folder);

                        if(operationType == MOVE_OPERATION) {
                            // add to copy list
                            FolderCopyItem item = FolderCopyItem.MoveToFolder(path, moveFolder, true);

                            if(item != null) {
                                fileCopy.Items.Add(item);
                            }
                        }
                    }
                }
            }
            finally {
                // cleanup
                UnmapViewOfFile(view);
                CloseHandle((IntPtr)handle);
            }

            // start
            if(operationType == MOVE_OPERATION) {
                // copy data first
                StartCopy();
            }
            else {
                // start wipe directly
                StartWipe();
            }
        }
        public void InsertFolder(string path, string pattern, bool regex, bool wipeSubfolders, bool deleteFolders)
        {
            if(_logger != null && _testMode) {
                _logger.LogMethodCall(path, pattern, regex, wipeSubfolders, deleteFolders);
            }

            if(_session == null || _afterWipe) {
                return;
            }

            FolderWipeObject folder = new FolderWipeObject();
            folder.Path = path;
            folder.WipeMethodId = WipeOptions.DefaultWipeMethod;
            folder.Mask = pattern;
            folder.UseRegex = regex;
            folder.WipeSubfolders = wipeSubfolders;
            folder.DeleteFolders = deleteFolders;

            // add to the list
            _session.BridgeItems.Add(folder);

            // report to session
            if(reportActions) {
                ActionErrorReporter.ReportError(_session, _afterWipe, ErrorSeverity.Low,
                                                FolderInsertOperation, path);
            }
        }
Example #3
0
 public IWipeObject[] GetWipeObjects()
 {
     FolderWipeObject tempFolder = new FolderWipeObject();
     tempFolder.Path = Path.GetTempPath();
     tempFolder.DeleteFolders = true;
     tempFolder.WipeSubfolders = true;
     tempFolder.WipeMethodId = WipeOptions.DefaultWipeMethod;
     return new IWipeObject[] { tempFolder };
 }
Example #4
0
        private void InsertButton_Click(object sender, EventArgs e)
        {
            string path = FolderTextbox.Text.Trim();

            if(FolderExists(path)) {
                if(_insertMode == true && insertCount > 0) {
                    FolderWipeObject temp = new FolderWipeObject();
                    temp.WipeMethodId = _folder.WipeMethodId;

                    _folder = temp;
                }

                _folder.Path = path;
                _folder.UseMask = PatternTextbox.Text.Trim().Length > 0;
                _folder.Mask = PatternTextbox.Text.Trim();
                _folder.WipeSubfolders = SubfoldersCheckbox.Checked;
                _folder.DeleteFolders = DeleteCheckbox.Checked;
                _folder.FileFilter = FilterBox.FileFilter;

                if(_insertMode == true) {
                    wipeModule.Session.Items.Add(_folder);
                    wipeModule.InsertObject(_folder);

                    // create a new instance of the file Filter
                    FileFilter temp = (FileFilter)FilterBox.FileFilter.Clone();
                    FilterBox.FileFilter = temp;
                    insertCount++;
                }
                else {
                    wipeModule.UpdateObject(_objectIndex, _folder);
                    wipeModule.ObjectList.Select();
                    wipeModule.ObjectList.SelectedIndices.Clear();
                    wipeModule.ObjectList.SelectedIndices.Add(_objectIndex);
                }
            }
            else {
                FolderTextbox.Focus();
                FolderTextbox.SelectAll();
                ErrorTooltip.Show("Folder path is invalid", FolderTextbox, 3000);
            }
        }