Lew Pitcher <lpitcher@teksavvy.com> writes:
> On August 25, 2011 12:29, in comp.lang.c, qp19433@hotmail.NOSPAM.com wrote:
>
>> Hi I am trying to delete a directory portably, using remove().
>
> remove() is not a portable function, and does not exist in ISO C.
Sorry, you're wrong. From C99 (but it wasn't new in C99):
7.19.4.1 The remove function
Synopsis
1 #include <stdio.h>
int remove(const char *filename);
Description
2 The remove function causes the file whose name is the string
pointed to by filename to be no longer accessible by that
name. A subsequent attempt to open that file using that name
will fail, unless it is created anew. If the file is open,
the behavior of the remove function is
implementation-defined.
Returns
3 The remove function returns zero if the operation succeeds,
nonzero if it fails.
> For that matter, the concept of directories also does not exist
> in ISO C,
You're right about that.
>> However it always returns EOF
>
> Not likely. You need to reread the documentation on that function.
> For instance, if you use the POSIX remove() function, then it either returns
> 0 for success or -1 for failure. If it returns -1, then "errno is
> set appropriately" for the error encountered.
EOF is commonly -1, so returning EOF on error is actually a
fairly likely outcome.
--
char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]
={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa67f6aaa,0xaa9aa9f6,0x11f6},*p
=b,i=24;for(;p+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
2:{i++;if(i)break;else default:continue;if(0)case 1:putchar(a[i&15]);break;}}}