如何知道文件是否实际打开或关闭?
How to know if a file is actually opened or closed?
Node.js 本机提供包文件系统,允许您读取、写入,尤其是监视文件。
我的问题是 fs watch 不允许您知道文件何时打开或关闭
我想知道是否有其他包可以做这个操作,你能帮我吗?
某些应用程序,如 word 在原始 word 文件的同一目录中创建临时文件
你可以检查它是否存在
试试这个工具:
https://github.com/ronomon/opened
这里提到:
Check if a file is open in another process
您可以使用 flag r+
。
fs.open('filename.doc','r+', function(err,data) {
// throws an error when the file is opened
});
Node.js 本机提供包文件系统,允许您读取、写入,尤其是监视文件。
我的问题是 fs watch 不允许您知道文件何时打开或关闭
我想知道是否有其他包可以做这个操作,你能帮我吗?
某些应用程序,如 word 在原始 word 文件的同一目录中创建临时文件
你可以检查它是否存在
试试这个工具: https://github.com/ronomon/opened
这里提到: Check if a file is open in another process
您可以使用 flag r+
。
fs.open('filename.doc','r+', function(err,data) {
// throws an error when the file is opened
});