diff options
author | Seppia <seppia@seppio.fish> | 2018-07-07 07:35:14 +0200 |
---|---|---|
committer | Seppia <seppia@seppio.fish> | 2018-07-07 07:35:14 +0200 |
commit | f6123e01a5bbcd809efc7a4546620e6150d4b610 (patch) | |
tree | 7811edbff7edfa46491cb2825845993f9a94a77c | |
parent | 43e1fd07c158efe656c5ba5d3c227a2858f69916 (diff) | |
download | onetimebluh-f6123e01a5bbcd809efc7a4546620e6150d4b610.tar.gz onetimebluh-f6123e01a5bbcd809efc7a4546620e6150d4b610.tar.bz2 onetimebluh-f6123e01a5bbcd809efc7a4546620e6150d4b610.zip |
Output file check
Moved output file existence check in specific functions, after all
options are parsed.
-rw-r--r-- | src/onetimebluh.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/onetimebluh.c b/src/onetimebluh.c index 2292827..db65a58 100644 --- a/src/onetimebluh.c +++ b/src/onetimebluh.c @@ -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"); } |