我有一个名为"Datas"的文件夹.此文件夹有一个名为"收件箱"的子文件夹,其中有多个".txt"文件.可以修改此"Datas"文件夹,最后会有多个带有"收件箱"子文件夹和".txt"文件的子文件夹.我需要监视"数据"文件夹和"收件箱"文件夹中的".txt"文件.我怎样才能做到这一点?
INotify只是监视文件夹并在创建子文件夹时弹出事件.如何在创建".txt"文件时弹出事件(在哪个文件夹中)?
我需要C或C++代码,但我被卡住了.我不知道如何解决这个问题.
我需要在具有多个子文件夹的文件夹上打印事件.如何递归呢?请打印一个c ++代码.我被困了!! 每次evet都是poped我需要打开子文件夹,取出文件并将其复制到另一个目录中.我不想每2秒列出所有子文件夹,如果有的话,找到文件.效率不高.我需要使用监视文件夹.请帮忙
我想要监控的导演有多个子文件夹.每个子文件夹都有另一个子文件夹,可以在一个时刻包含一个文件.MainFolder->子文件夹 - >每个子文件夹 - >子文件夹 - >文件.
以下是我的代码:
/*
*/
#include <pthread.h>
#include <unistd.h>
#include <iostream>
#include <sys/inotify.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/inotify.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
using namespace std;
vector<string> SS;
void *print_message_function( void *ptr );
int main(int argc, char **argv ){
pthread_t t1;
int fd,fd1,wd,wd1,i=0,i1=0,len=0,len1=0;
int length;
char pathname[100],buf[1024],buf1[1024];
int data;
struct inotify_event *event;
char *message1 = "Thread 1";
FILE …Run Code Online (Sandbox Code Playgroud)