Re: Should fopen() create missing path components?

(Jerry Heyman) <[email protected]> Fri, 07 Nov 2003 13:39:42 -0500
Newsgroups gmane.comp.ide.emx.devel
Message-ID <[email protected]>
On 7 November 2003 at 11:12, "Thomas Hoffmann" <[email protected]> wrote:
> A supposedly simple question, but I did not find a definitive answer in
> any of the documents I looked through: If I give to fopen(fna,"w") a
> file name with path components that do not exist yet: Should fopen()
> silently create all path components, should it fail (as it does on my
> system with errno=ENOENT) or is this up to the implementation?

from the man pages of fopen() on my Unix system (aix) -

ERRORS
   EINVAL The mode provided to fopen, fdopen, or freopen was invalid.

The fopen, fdopen and freopen functions may also fail and set errno for
any of the errors specified for the routine malloc(3).

The  fopen  function  may also fail and set errno for any of the errors
specified for the routine open(2).

The  freopen function may also fail and set errno for any of the errors
specified for the routines open(2), fclose(3) and fflush(3).

from open() -

ERRORS
   EEXIST pathname already exists and O_CREAT and O_EXCL were used.
   EISDIR pathname refers to a directory and the access requested involved
          writing (that is, O_WRONLY or O_RDWR is set).
   EACCES The  requested  access to the file is not allowed, or one of the
          directories in pathname did not allow search  (execute)  permis-
          sion, or the file did not exist yet and write access to the par-
	  ent directory is not allowed.  
   ENAMETOOLONG pathname was too long.
   ENOENT O_CREAT is not set and the named file does  not  exist.   Or,  a
          directory  component in pathname does not exist or is a dangling
	  symbolic link.
   ENOTDIR A component used as a directory in pathname is not, in  fact,  a
           directory,  or  O_DIRECTORY was specified and pathname was not a 
	   directory.

[ ... code deleted ... ]

> --
> Thomas Hoffmann
> [email protected]                                  Dresden, Germany
> 
> .sig under construction ...

jerry
Jerry Heyman   919.224.1442   | IBM SWG/Tivoli Software|"Software is the 
Build Infrastructure Architect| 3901 S Miami Blvd      | difference between
jheyman-r/[email protected]            | Durham, NC  27703      | hardware and reality"
                      http://www.cs.stedwards.edu/~heyman