Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
A few minor bugfixes and tweaks to cover more of the program
  • Loading branch information
rushsteve1 committed Sep 8, 2021
1 parent 6edfb8f commit fb46429
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
3 changes: 0 additions & 3 deletions CMakeLists.txt

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -34,7 +34,7 @@ portable.

You can build it with Dub using `dub build` and run tests with `dub test`.

Alternatively you can build with GDC using `gdc source/trash.d source/app.d -o trash`.
CMake build files can be generated using `dub generate cmake`.

### Installing

Expand Down
2 changes: 2 additions & 0 deletions source/app.d
Expand Up @@ -27,6 +27,8 @@ int main(string[] args) {
switch (res) {
case 0:
break;
// This is a special case where the options parsing wants to stop
// execution but there was no error
case -1:
return 0;
default:
Expand Down
6 changes: 5 additions & 1 deletion source/operations.d
Expand Up @@ -167,7 +167,11 @@ int restoreOrDel(in string name, bool del) {
if (del) {
tfile.file_path.remove();
} else {
tfile.file_path.renameOrCopy(tfile.orig_path);
// If the original desination is writeable
if (tfile.writeable
|| prompt("%s is write protected, attempt restore anyway?", tfile.orig_path)) {
tfile.file_path.renameOrCopy(tfile.orig_path);
}
}
// Always remove the trashinfo file
tfile.info_path.remove();
Expand Down
5 changes: 4 additions & 1 deletion source/tests.d
Expand Up @@ -165,7 +165,7 @@ unittest {
Test recursively trashing a folder then emptying the trash
*/
unittest {
string testdir = "test-dir";
string testdir = "test-dir/";
testdir.mkdir();
scope (failure)
testdir.rmdirRecurse();
Expand Down Expand Up @@ -205,6 +205,9 @@ unittest {
assert(OPTS.info_dir.exists());
assert(OPTS.dirsize_file.exists());

// Empty operands should error
assert(mini(["-f"]) == 1);

// Cleanup
scope (success)
test_trash_dir.rmdirRecurse();
Expand Down

0 comments on commit fb46429

Please sign in to comment.