iNotify可以告诉我受监视文件的位置吗? [英] Can iNotify tell me where a monitored file is moved?

查看:85
本文介绍了iNotify可以告诉我受监视文件的位置吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想监视文件在系统中移动的过程.每当移动时,iNotify可以告诉我它的新位置吗?

I want to monitor a file while it's moving in the system. Can iNotify tell me its new position whenever it's moves?

推荐答案

如果您正在观看文件从中移动的目录和文件在其中移动的目录,则您将在上收到一个IN_MOVED_FROM事件源目录和目标目录上的IN_MOVED_TO事件,两者都具有相同的cookie.然后,您可以使用两个事件的name字段来查找文件的移入和移出位置.

If you're watching both the directory the file was moved from, and the directory the file was moved to, then you will receive an IN_MOVED_FROM event on the source directory and an IN_MOVED_TO event on the target directory, both with the same cookie. You can then use the name fields of the two events to find out where the file was moved to and from.

如果仅查看源目录或目标目录,则将仅获得事件之一,因此仅获得一半的信息.这是inotify的局限性.

If you're only watching the source directory, or only the target directory, then you will only get one of the events, so you will only have half of the info. This is a limitation of inotify.

这篇关于iNotify可以告诉我受监视文件的位置吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆