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

问题描述

我有成千上万的文件需要检查其退出。

我认为fstat对此来说成本太高。

有没有更好的方法呢?

解决方案



OT这里,但在POSIX你会有stat()(这会省你fopen())

和访问权限()(这应该便宜很多,因为它不需要填写

整个结构数据)。


再见,Jojo




我怀疑access()会显着便宜,因为它仍然需要

来进行系统调用并获取文件的inode。


- Richard

-

:wq




我怀疑access()会显着便宜,因为它仍然需要

来进行系统调用并获取文件的inode。



我经常使用的系统便宜得多。


再见,Jojo

I have thousands of files whose exitence needs to be checked.
I think fstat is too costly for this.
Is there any better way for the same ?

解决方案

OT here, but in POSIX you''d have stat() (which would save you the fopen())
and access() (which should be much cheaper as it doesn''t have to fill the
entire struct stat).

Bye, Jojo


I doubt access() would be significantly cheaper since it still has
to do a system call and get the inode of the file.

-- Richard
--
:wq



I doubt access() would be significantly cheaper since it still has
to do a system call and get the inode of the file.

It is significantly cheaper on a system I frequently work with.

Bye, Jojo


这篇关于替代fstat?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 19:45