Xref: news-dnh.mv.net comp.os.msdos.djgpp:1809 Path: news-dnh.mv.net!mv!news.sprintlink.net!in2.uu.net!EU.net!i2unix!news.mclink.it!news From: mc5686 AT mclink DOT it (Mauro Condarelli) Newsgroups: comp.os.msdos.djgpp Subject: Re: mkdir and errno in V2 Date: Sun, 27 Aug 1995 22:32:06 GMT Organization: MC-link The World On Line Lines: 31 References: Nntp-Posting-Host: 192.106.166.228 To: djgpp AT sun DOT soe DOT clarkson DOT edu Dj-Gateway: from newsgroup comp.os.msdos.djgpp Marc Singer wrote: >It appears that the mkdir call does not clear errno on success. My >code is creating a new path by starting at the full length trying to >create the directory. On failure, it removes the last path element >and tries again until it succeeds. As soon as it does so, it replaces >the path elements one at a time and creates the path one directory at >a time. >Since it fails once, errno is ENOTDIR. The successful mkdir calls do >not clear this value so errno on exit from my procedure is still >ENOTDIR. I patch my procedure by clearing errno before each call to >mkdir. >I'm porting this code fragment as part of CVS. I notice that the >procedure assumes that mkdir returns ENOENT when the directory cannot >be created. Is the ENOTDIR an incorrect return value? ENOENT is what >the Linux libc returns. I don't think any of the lib functions clears errno. All functions return values that let you know if the function suceeded, if not then errno gives the reason why, else it is trash (the previous value). Is this the POSIX behaviour? can someone check?? Surely it is widespread enough. Anyway the bottom line is: if it went OK don't look errno. Saludos Mauro Condarelli (mc5686 AT mclink DOT it)