May I propose an add to standard library, namely method mkpath to class Dir.
(For non-unix-persons, the method makes all the directories needed to have
all directories in the given path.) Here's a definition (just hacked, once
tested, so beware):
class Dir
def Dir.mkpath(path)
dname = ''
path.split('/').each do |tmp|
dname << tmp + "/"
Dir.mkdir dname unless File.directory? dname
end
end
end
I've coded this method twice, and I just tried to install one kit from RAA
implementing the same thing. I failed to install because it had a bug. So I
fixed it, but started to think that maybe people shouldn't recode this all
the time.
I'm afraid this version isn't good enough to be translated to C immediately
(like, I just noted it might be good to use File.SEPARATOR instead of '/',
maybe add some error handling, handle permissions and umask etc) but this is
just start for discussion.
- Aleksi