c++ - Inotify - event->name gives subdirectories, not the main directories -
i have been writing program print name of file being accessed , time file accessed. basically, instead of getting file path name type in, getting names of subdirectories of file. suspect has event->name using toward end of program. there other function should using instead?
the code follows:
string filename; printf("please enter file path name: "); getline(cin, filename); /*create list<string> multiple files entered*/ list<string> stringlist; list<string>::iterator it; stringlist.push_back(filename); = stringlist.begin(); while(filename != "exit") { /*check whether files exists. prompt user re-enter filename*/ while(fileexists(filename) == false ) { printf("file %s not exist. try again.\n", filename.c_str()); printf("please enter file path name: "); getline(cin, filename); } printf("please enter next file: "); getline(cin, filename); if(filename != "exit") stringlist.push_back(filename); } int index = 0; wd = 0; length = read(fd, buffer, buf_len); while(i < length) { struct inotify_event* event = (struct inotify_event * ) &buffer[i]; if(event->mask & in_access) { log.writefile(event->name); } i+= event_size + event->len; }
Comments
Post a Comment