FSEvents和复制大文件

FSEvents和复制大文件

本文介绍了FSEvents和复制大文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用FSEvents来监视一个文件的目录,这个文件将会有一些大文件复制到它的目录中。目前FSEvents似乎在我开始复制文件时发出通知,并在复制完文件后再次发出通知。当它是一个较小的文件,但我只得到一个事件。有没有办法检查一个文件是否被复制?



顺便说一下,这是Snow Leopard。

I'm using FSEvents to monitor a directory of files that will have some large files copied into it. Currently FSEvents seems to be sending out a notification when I've begun copying the file, and again when it's finished copying the file. When it's a smaller file though, I only get the one event. Is there any way to check if a file is in the middle of being copied?

This is for Snow Leopard by the way.

解决方案

I ended up just using lsof to check if the file is open at a kernel level. I only begin processing the file once lsof has determined that the file is no longer in use.

这篇关于FSEvents和复制大文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 23:40