Find and delete (unlink) all the files in the directory (under Unix use the opendir, readdir, closedir calls, under Window$ use the FindFirst and FindNext calls) then delete the dir.
You would need to call stat() for your files to be safe
and check the value using the macros S_ISDIR and S_ISREG
so you can implement further (?recursive?)subdirectory removal.
Needless to say error checking is all up to you.
yes marsd: i did not really read your code
your way is sure better then the lazy: system("rm -rf xxx"
please do not re-invent 'basename()'
say extern char *basename(char *);
in your protos dont include the <name>
not: int rmfile(char *name);
but: int rmfile(char *);
-----------
when they don't ask you anymore, where they are come from, and they don't tell you anymore, where they go ... you'r getting older !
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.