个人工具
登录
查看“Inotify编程接口”的源代码 - Ubuntu中文
页面
讨论
查看源代码
历史
搜索
导航
首页
最近更改
随机页面
页面分类
帮助
编辑
编辑指南
沙盒
新闻动态
字词处理
工具
链入页面
相关更改
特殊页面
页面信息
查看“Inotify编程接口”的源代码
来自Ubuntu中文
←
Inotify编程接口
跳转至:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
<pre> #include<stdio.h> #include<unistd.h> #include<sys/inotify.h> #define MAX_EVENTS 256 #define BUFFER_SIZE (MAX_EVENTS * sizeof(struct inotify_event)) int main(int argc , char *argv[]) { int i=0; int len; int inotify_fd; int inotify_wd; int inotify_err; struct inotify_event *ievent; if( argc != 2 ) { printf("no input !"); return -1; } inotify_fd = inotify_init(); if ( inotify_fd < 0 ) printf("can't init inotify "); inotify_wd=inotify_add_watch(inotify_fd, argv[1] , IN_CREATE ); while(1) { i=0; char ev_buffer[BUFFER_SIZE]; len= read(inotify_fd, ev_buffer,BUFFER_SIZE); while(i<len) { ievent=(struct inotify_event *)&ev_buffer[i]; if (ievent->len) printf("[%s]",ievent->name); if(ievent->mask & IN_CREATE ) printf("create"); } } } </pre>
返回至
Inotify编程接口
。