summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOskar <[email protected]>2024-07-21 19:34:14 +0200
committerOskar <[email protected]>2024-07-21 19:34:14 +0200
commit72af06562592779941096fe2f1fd28ee600c89a0 (patch)
tree07ac6abdc75ebb9fd67fb1d834083ce932fff3bf
parent2e08693557019529cf8a4daa7931d3414cbeca51 (diff)
new textscripts and some new getopt stuff
-rwxr-xr-xtest/test_deletefiles_tmp.sh6
-rwxr-xr-xtest/test_generate_delete_tmp.sh7
-rw-r--r--trashsys.c56
3 files changed, 37 insertions, 32 deletions
diff --git a/test/test_deletefiles_tmp.sh b/test/test_deletefiles_tmp.sh
new file mode 100755
index 0000000..deb070f
--- /dev/null
+++ b/test/test_deletefiles_tmp.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+files="1000b.img 1000mb.img 1023b.img 1023kib.img 1024b.img 1024kib.img 1.1gib.img 1gib.img 1KB.img 1KiB.img 1mb.img 1mib.img 500kib.img thisfile.txt ts_file1.txt ts_file2.txt ts_file3.txt"
+options="-v -t"
+
+./tsr-TESTING $options $files
diff --git a/test/test_generate_delete_tmp.sh b/test/test_generate_delete_tmp.sh
new file mode 100755
index 0000000..0eed94c
--- /dev/null
+++ b/test/test_generate_delete_tmp.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+for i in {1..10}
+do
+ ./gentestfiles.sh
+ ./test_deletefiles_tmp.sh
+done
diff --git a/trashsys.c b/trashsys.c
index c34b264..7220337 100644
--- a/trashsys.c
+++ b/trashsys.c
@@ -800,10 +800,10 @@ int compare_unixtime (time_t deleted_time, int difference_in_days) {
final = current_time - deleted_time;
if(final < diff_converted) {
- cvm_fprintf(v_cvm_fprintf, stdout, "final is not older than diff_converted");
+ cvm_fprintf(v_cvm_fprintf, stdout, "final is not older than diff_converted\n");
return FUNCTION_FAILURE;
}
- cvm_fprintf(v_cvm_fprintf, stdout, "final is older than diff_converted");
+ cvm_fprintf(v_cvm_fprintf, stdout, "final is older than diff_converted\n");
return FUNCTION_SUCCESS;
}
@@ -812,30 +812,6 @@ int clear_old_files (int file_age_in_days, struct initial_path_info *ipi) {
struct list_file_content *lfc = fill_lfc(ipi);
struct list_file_content *walk;
int i = 1;
- //int lfc_formatted (struct list_file_content *lfc, const bool L_used)
- /*
- struct list_file_content {
- char ID[PATH_MAX];
- char filename[PATH_MAX];
- char trashed_filename[PATH_MAX];
- char filesize[PATH_MAX];
- char time[PATH_MAX];
- char originalpath[PATH_MAX];
- char tmp[PATH_MAX];
- struct list_file_content *next;
- };
-
- struct initial_path_info { // Initial useful strings to create before we do anything. Super useful when programming.
- char ts_path_user_home[PATH_MAX];
- char ts_path_trashsys[PATH_MAX];
- char ts_path_log[PATH_MAX];
- char ts_path_trashed[PATH_MAX];
- char ts_path_user_home_withslash[PATH_MAX];
- char ts_path_trashsys_withslash[PATH_MAX];
- char ts_path_log_withslash[PATH_MAX];
- char ts_path_trashed_withslash[PATH_MAX];
- };
- */
if(lfc == NULL) { return EXIT_SUCCESS; }
for(walk = lfc ; walk != NULL ; walk = walk->next, i++) {
char *endptr;
@@ -887,7 +863,12 @@ int main (int argc, char *argv[]) {
USAGE_OUT(stderr);
return EXIT_FAILURE;
}
-
+
+ int R_mut = 0;
+ int C_mut = 0;
+ int c_mut = 0;
+ int L_mut = 0;
+ int l_mut = 0;
bool y_used = false;
bool n_used = false;
bool v_used = false;
@@ -936,27 +917,32 @@ int main (int argc, char *argv[]) {
break;
case 'l':
-
+
+ l_mut = 1;
l_used = true;
break;
case 'L':
-
+
+ L_mut = 1;
L_used = true;
break;
case 'c':
-
+
+ c_mut = 1;
c_used = true;
break;
case 'C':
-
+
+ C_mut = 1;
C_used = true;
break;
case 'R':
-
+
+ R_mut = 1;
R_used = true;
break;
@@ -966,6 +952,12 @@ int main (int argc, char *argv[]) {
break;
}
}
+
+ if((R_mut + C_mut + c_mut + L_mut + l_mut) > 1) {
+ USAGE_OUT(stderr);
+ return EXIT_FAILURE;
+ }
+
if(optind == argc && (l_used || L_used || C_used || c_used) == false) {
USAGE_OUT(stderr);
return EXIT_FAILURE;