fopen functioin

U

upendrao

Hi
I have a problem with fopen function call. fopen could not
differentiate between a valid file path and a valid directory path. In
both cases it returns a non-NULL file descriptor value. Is there any
way in GNU C library to differentiate between a valid file name and
directory name?
 
W

Walter Roberson

: I have a problem with fopen function call. fopen could not
:differentiate between a valid file path and a valid directory path. In
:both cases it returns a non-NULL file descriptor value. Is there any
:way in GNU C library to differentiate between a valid file name and
:directory name?

Standard C does not know anything about directories, so there
is no -portable- way of doing it -- it depends on the semantics
provided by the hosting system.

As you specified "GNU C", portability is clearly not your main
concern, so you might wish to fstat() that which you have opened.
 
P

pete

Walter said:
: I have a problem with fopen function call. fopen could not
:differentiate between a valid file path
:and a valid directory path. In
:both cases it returns a non-NULL file descriptor value. Is there any
:way in GNU C library to differentiate between a valid file name and
:directory name?
-- it depends on the semantics provided by the hosting system.

A directory may be a file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top