File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ void add_watch(int fd, const std::string& path) {
1313 perror (" inotify_add_watch" );
1414 return ;
1515 }
16+
1617
1718 // Open the directory and iterate through its entries
1819 DIR* dir = opendir (path.c_str ());
@@ -39,8 +40,12 @@ void add_watch(int fd, const std::string& path) {
3940 closedir (dir);
4041}
4142
42- int main () {
43- const std::string directory_to_watch = " /home/dir/owl/" ; // Change this to your target directory
43+ int main (int argc, char * argv[]) {
44+ if (argc < 2 ) {
45+ std::cerr << " Usage: " << argv[0 ] << " <directory_to_watch>" << std::endl;
46+ return EXIT_FAILURE;
47+ }
48+ const std::string directory_to_watch = argv[1 ]; // Get the directory to watch from command-line argument
4449
4550 // Create an inotify instance
4651 int fd = inotify_init ();
You can’t perform that action at this time.
0 commit comments