Hopefully fixed

This commit is contained in:
Pierre Pronchery 2005-04-09 22:40:13 +00:00
parent 06bf7ae78c
commit c1a1d026c4

View File

@ -16,16 +16,10 @@ static int _rmdir(int flagp, int argc, char * argv[])
for(i = 0; i < argc; i++) for(i = 0; i < argc; i++)
{ {
if(rmdir(argv[i]) == -1) if(rmdir(argv[i]) != 0)
{
res = _rmdir_error(argv[i], 2); res = _rmdir_error(argv[i], 2);
continue; if(flagp && _rmdir_p(argv[i]) != 0)
} res = 2;
if(flagp)
{
if(_rmdir_p(argv[i]) == -1)
res = 2;
}
} }
return res; return res;
} }
@ -41,13 +35,15 @@ static int _rmdir_p(char * pathname)
{ {
char * str; char * str;
str = pathname; for(str = pathname; *str != '\0'; str++);
while(*str++); for(str--; str > pathname && *str == '/'; str--);
while(--str != pathname) while(--str > pathname)
{ {
if(*str != '/') if(*str != '/')
continue; continue;
*str = '\0'; for(*str = '\0'; --str > pathname && *str == '/'; *str = '\0');
if(*str == '\0')
return 0;
if(rmdir(pathname) == -1) if(rmdir(pathname) == -1)
return _rmdir_error(pathname, 2); return _rmdir_error(pathname, 2);
} }