diff options
-rw-r--r-- | onetimebluh.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/onetimebluh.c b/onetimebluh.c index b665fa3..0b4774a 100644 --- a/onetimebluh.c +++ b/onetimebluh.c @@ -50,6 +50,9 @@ int main(int argc, char* argv[]) { break; case 'e': message = argv[optind-1]; + if (access(message, F_OK) == -1) { /* checks the existence of the file and eventually exits */ + error(errno, errno, message); + } command++; comm = 'e'; break; @@ -63,6 +66,9 @@ int main(int argc, char* argv[]) { break; case 'k': keyfile = argv[optind-1]; + if (access(keyfile, F_OK) == -1) { /* look at the comment before */ + error(errno, errno, keyfile); + } break; case 'o': output = argv[optind-1]; @@ -110,14 +116,6 @@ void xor(int ed, char* mess, char* keyf, char* outp) { char* defenoutp = "critt"; char* defdeoutp = "decritt"; - /* Following if-else block check the existence of the files */ - - if (access(mess, F_OK) == -1) { - error(errno, errno, mess); - } else if (access(keyf, F_OK) == -1) { - error(errno, errno, keyf); - } - /* In absence of input by users nex block sets the default values */ if (outp == NULL) { |