This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: directory opening/closing behavior


> Exactly what you've described. It's a 
> Windows feature which isn't POSIX compatible 
> and for which a workaround would be
> extremly difficult.

Sorry, this isn't a "Windows feature" but 
POSIX compatible and a workaround would be 
extremly simple, because Chad Fowler made
a simple mistake: he forgotten to call 
closedir() before rmdir():

#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>

/* (1) */
#include <sys/dirent.h>

int main(void)
{
 int rc;
 extern int errno;

 /* (2) */
 DIR* pDIR; 

 rc = mkdir("_blah", 0777);
 printf("mkdir %d\n", rc);

 pDIR = opendir("_blah");
 printf("opendir %d\n", ( long ) pDIR);

 /* (3) */
 rc = closedir( pDIR );
 printf("closedir %d\n", rc);

 rc = rmdir("_blah");
 printf("rmdir %d\n", rc);

 rc = mkdir("_blah", 0777);
 printf("mkdir %d\n", rc);
 printf("errno: %d\n", errno);
}

#if 0

Cygwin output:
mkdir 0
opendir 167839600
closedir 0
rmdir 0
mkdir 0
errno: 0

Linux output:
mkdir 0
opendir 134518696
rmdir 0
mkdir 0
errno: 38

#endif

----- Original Message ----- 
From: "Corinna Vinschen" <cygwin@cygwin.com>
To: <cygwin@cygwin.com>
Sent: Sunday, November 18, 2001 10:12 AM
Subject: Re: directory opening/closing behavior


> On Sat, Nov 17, 2001 at 03:47:33PM -0800, chad fowler wrote:
> > Cygwin output:
> > mkdir 0
> > opendir 167839552
> > rmdir 0
> > mkdir -1
> > errno: 13
> > 
> > Linux output:
> > mkdir 0
> > opendir 134518696
> > rmdir 0
> > mkdir 0
> > errno: 38
> > 
> > After having run, the directory "_blah" exists in
> > Linux but doesn't exist in Cygwin.
> > 
> > What's the expected behavior?
> 
> Exactly what you've described. It's a Windows feature which
> isn't POSIX compatible and for which a workaround would be
> extremly difficult.
> 
> Corinna
> 
> -- 
> Corinna Vinschen Please, send mails regarding Cygwin to
> Cygwin Developer mailto:cygwin@cygwin.com
> Red Hat, Inc.
> 
> --
> Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
> Bug reporting: http://cygwin.com/bugs.html
> Documentation: http://cygwin.com/docs.html
> FAQ: http://cygwin.com/faq/
> 
> 
> 
> 
______________________________________________________
Kein Schwein klickt mich an? Tragen Sie Ihre Site doch einfach im
Fireballkatalog ein! http://www.fireball.de/katalogeintrag.html



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]