This is the mail archive of the cygwin 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: Solved. Odd, is it not? mkdir 'e:\' cannot be undone by rmdir 'e:\' ...


On Sat, 21 Sep 2019 21:02:37, Ken Brown  wrote:
[snip]

> I think you can simplify this by eliminating the second part and changing
> the first part to the following:
> 
>          char sep = dir[strlen (dir) - 1];
>          if (isdirsep (sep)
>            {
>              /* This converts // to /, but since both give EEXIST, we're okay. */
>              char *buf;
>              char *p = stpcpy (buf = tp.c_get (), dir) - 1;
>              dir = buf;
>              while (p > dir && isdirsep (*p))
>                *p-- = '\0';
>              /* Reattach dirsep in case of "x:". */
>              if (p == dir + 1 && *p == ':' && isalpha (dir[0]))
>                p[1] = sep;
>            }

Hi Ken,

The ball is your court now. Having said that, in case of multiple trailing
dirseps, your code will reattach the last one.

My code will reattach the first dirsep, not the last one.

And dirseps can be both \ and /.

But again, the ball is your court now ...

Regards,
Henri

=====


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


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