不可见的硬链接
我有一个小应用程序,用于显示日志文件的内容,为了可读性而进行了一些变形。由于日志文件偶尔会被重写,并且 Windows 文件系统语义禁止删除打开的文件,因此我创建了该文件的硬链接。
显然,这需要发生在与原始文件相同的文件系统上——目前,我在同一目录中创建硬盘,我相信可以合理地假设它可以满足此要求;结果是一个临时文件出现在用户刚刚单击打开文件的目录列表中,这很丑陋。
有没有办法创建硬链接,使其不显示(使用该程序的客户在其目录树中有多个连接点,因此不能假设特定目录位于同一文件系统上),或者是否有一种更好的方法来读取另一个进程可能想要删除和重写的文件(例如,通过捕获它们的访问并在让其他进程的访问通过之前关闭该文件),因此该程序可以在存档(只读)日志文件上使用,而无需修改?
I have a small application that displays the contents of a log file, somewhat transmogrified for readability. As the log file gets rewritten occasionally and Windows file system semantics prohibit deletion of open files, I create a hardlink to the file.
Obviously, this needs to happen on the same file system as the original file -- at present, I create the harddisk in the same directory, which I believe can be reasonably assumed to fulfill this requirement; the result is that a temporary file shows up in the directory listing where the user just clicked to open the file, which is ugly.
Is there a way to create a hardlink so that it does not show up (the customer where the program is used has several junctions in their directory tree, so it cannot be assumed that a specific directory is on the same filesystem), or is there a better method to read a file that another process may want to delete and rewrite (e.g. by catching their access and closing the file before letting the other process's access go through), so the program can be used on archived (readonly) log files without modification?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)