你如何检查一个文件是否使用Perl打开? [英] How do you check if a file is open using Perl?

查看:106
本文介绍了你如何检查一个文件是否使用Perl打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定一个文件的名称,我怎样才能确定文件是目前打开或正在使用? (我正在讨论文件而不是Perl文件句柄。)

请注意,我正在寻找一种通用的Perl解决方案,而不是特定于操作系统的解决方案。至少,我希望在Windows和基于GNU / Linux的系统上都可以运行。

解决方案

POSIX不提供任何方式来做到这一点。因此,考虑到当前的可用便携式O / S接口,没有便携式解决方案。

您必须制定一些更高级别的方法,为开放位提供单一访问点。这就像锁文件。

Given the name of a file, how can I determine if the file is currently opened or in-use? (I am talking about files rather than Perl file handles.)

Please note that I am looking for a general-purpose Perl solution rather than an operating system-specific one. At a minimum, I would like something that works both on Windows and GNU/Linux-based systems.

解决方案

POSIX does not provide any way to do this. Therefore, no portable solution is possible given the current portable O/S interface available.

You’d have to craft some higher level approach that provides a single point of access for the opening bits. It’s like with lock files.

这篇关于你如何检查一个文件是否使用Perl打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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