文件打开时,access()不起作用 [英] access() doesn't work when a file is open

查看:85
本文介绍了文件打开时,access()不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨:


我遇到了一个奇怪的问题。


我打开了一个文件File1使用fopen()并在循环中处理文件中的

记录时,我调用access()来检查

是否存在File2。原因是当文件File2时,停止处理进一步的记录

。存在。但是当文件

" File1"时,access()调用失败。是开放的。


如果我关闭File1在打电话给File2上的access()之前,那么

有效。为什么会这样?


请帮忙。请原谅我的C无知。


Regds..Shyam

Hi:

I am facing a strange problem.

I have opened a file "File1" using fopen() and while processing the
records in the file in a loop, I have a call to access() to check
existence of "File2". The reason is to stop processing further records
when the file "File2" exists. But the access() call fails when the file
"File1" is open.

If I close "File1" before making a call to access() on "File2", then it
works. Why is this behavior?

Please help. And please excuse my C ignorance.

Regds..Shyam

推荐答案


ps**********@yahoo.com 写道:
嗨:

我正面临一个奇怪的问题。

我打开了一个文件File1。使用fopen()并在循环中处理文件中的
记录时,我调用access()来检查
是否存在File2。原因是当文件File2时,停止处理进一步的记录。存在。但是当文件
File1时,access()调用失败。开了。


你检查错误了吗? aceess()失败时应该设置errno。

看看你是否能找到一些东西。猜猜不会再把我们带走了。

如果我关闭File1在调用File2上的access()之前,它就可以了。为什么会出现这种情况?
Hi:

I am facing a strange problem.

I have opened a file "File1" using fopen() and while processing the
records in the file in a loop, I have a call to access() to check
existence of "File2". The reason is to stop processing further records
when the file "File2" exists. But the access() call fails when the file
"File1" is open.
Did you check for the error? aceess() on failure should set errno.
See if you can find out something. Guessing won''t take us any further.
If I close "File1" before making a call to access() on "File2", then it
works. Why is this behavior?




不知道!



No idea!


ps ********** @ yahoo.com 写道:

我打开了一个文件File1使用fopen()并在循环中处理文件中的记录时,我调用access()来检查File2的存在。原因是当文件File2时,停止处理进一步的记录。存在。但是当文件File1调用时,access()
调用失败。是开放的。

如果我关闭File1在调用File2上的access()之前,
然后就可以了。为什么会出现这种情况?

I have opened a file "File1" using fopen() and while processing
the records in the file in a loop, I have a call to access() to
check existence of "File2". The reason is to stop processing
further records when the file "File2" exists. But the access()
call fails when the file "File1" is open.

If I close "File1" before making a call to access() on "File2",
then it works. Why is this behavior?




标准C中没有access()这样的函数,所以它必须是你自己编写的
或由您的系统提供。这个

使这个主题偏离主题。你可以提供完整的

访问来源(),以及你的实际代码,我们什么时候能够对它进行评论,或者你应该找到一个新闻组用您的系统处理




如果您想通过groups.google.com发布后续内容,请不要使用

已损坏回复链接在文章的底部。点击显示

选项在文章的顶部,然后点击回复在

文章标题的底部。


-

查克F(cb ******** @ yahoo.com)(cb********@worldnet.att.net)

可用于咨询/临时嵌入式和系统。

< http ://cbfalconer.home.att.net>使用worldnet地址!



There is no such function as access() in standard C, so it must be
something you wrote yourself or provided by your system. This
makes the subject off-topic here. You can either provide the full
source of access(), together with your actual code, when we will be
able to comment on it, or you should find a newsgroup that deals
with your system.

If you want to post a followup via groups.google.com, don''t use the
broken "Reply" link at the bottom of the article. Click on "show
options" at the top of the article, then click on the "Reply" at
the bottom of the article headers.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!


access()是Unix上可用的api,用于确定

文件的可访问性。它适用于所有标准的Unix风格。

access() is an api available on Unix to determine accessibility of a
file. It is on all standard Unix flavors.


这篇关于文件打开时,access()不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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