Skip to content

Commit 582ce10

Browse files
Update file_owl.cpp
++added get directory path from user parameter
1 parent b41a658 commit 582ce10

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/file_owl.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff 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();

0 commit comments

Comments
 (0)