Commit f6123e01 authored by Seppia's avatar Seppia

Output file check

Moved output file existence check in specific functions, after all
options are parsed.
parent 43e1fd07
......@@ -107,9 +107,6 @@ int main (int argc, char* argv[]) {
break;
case 'o':
opzioni.output = argv[optind-1];
if (!access (opzioni.output, F_OK)) {
qprintf (opzioni.quiet, "WARNING: %s file exists in filesystem and will be overwritten!", opzioni.output);
}
break;
case 'q':
opzioni.quiet = 1;
......@@ -176,6 +173,9 @@ void xor (Opts* opzioni) {
}
if (opzioni->output) {
if (!access (opzioni->output, F_OK)) {
qprintf (opzioni->quiet, "WARNING: %s file exists in filesystem and will be overwritten!\n", opzioni->output);
}
critt = fopen (opzioni->output, "w");
}
......@@ -261,6 +261,10 @@ void keyrand (Opts* opzioni) {
RAND_bytes (key, opzioni->nbytes);
if (opzioni->output) {
if (!access (opzioni->output, F_OK)) {
qprintf (opzioni->quiet, "WARNING: %s file exists in filesystem and will be overwritten!\n", opzioni->output);
}
FILE* file;
file = fopen (opzioni->output, "w");
......@@ -302,6 +306,9 @@ void bluh (Opts* opzioni) {
}
if (opzioni->output) {
if (!access (opzioni->output, F_OK)) {
qprintf (opzioni->quiet, "WARNING: %s file exists in filesystem and will be overwritten!\n", opzioni->output);
}
bluh = fopen (opzioni->output, "w");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment