rm utility

So, I've been rewriting some simple command line utilities. Like echo, cat and rm. Just for the excercise. They are, as you may have guessed fairly simple to reproduce. But I'm having one problem that I just can't find a solution to. And that's in the rm utility. If a folder contains files, it wont delete it. I have looked all over the web for a decent solution and could not find one. I was hoping some of you smart people might have a solution for me.

My problem is actually two fold.
1) I don't know how to produce an appropriate error when a directory contains files, vs. a simple == 0
2) I can't figure out how to recursively delete folders. I tried using remove with wildcards. But as you know, a /* produces a comment!

Any suggestions?

*edit* Actually, on second thought...I dont really need a solution to an appropriate error message. It reminds me of windows, 'are you sure?' lol! I simply want the ability to recursively delete folders.

I know I could simply do this from the command line parameters, but I would like to include it by default in my program.
Last edited on
closed account (48T7M4Gy)
http://www.cplusplus.com/forum/windows/27121/
Topic archived. No new replies allowed.