summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSeppia <seppia@seppio.fish>2018-07-07 07:35:14 +0200
committerSeppia <seppia@seppio.fish>2018-07-07 07:35:14 +0200
commitf6123e01a5bbcd809efc7a4546620e6150d4b610 (patch)
tree7811edbff7edfa46491cb2825845993f9a94a77c /src
parent43e1fd07c158efe656c5ba5d3c227a2858f69916 (diff)
downloadonetimebluh-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.
Diffstat (limited to 'src')
-rw-r--r--src/onetimebluh.c13
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");
}