Ruby Forum Ruby-core > Dir.mkdir would be better if it returned a Dir object

Posted by Nikolai Weibull (Guest)
on 24.04.2008 14:42
(Received via mailing list)
Dir.mkdir creates a directory and returns 0 on success.  It would be
better if Dir.mkdir returned a new Dir object that wrapped the file
descriptor that mkdir(2) returns.

My immediate use case is that this would allow you to create temporary
directories as safely as files can currently be created.

I'll gladly write the patch (and even more gladly let someone else do
it for me), but I would like input on this before I do.

Thanks!
Posted by Urabe Shyouhei (Guest)
on 25.04.2008 06:03
(Received via mailing list)
Nikolai Weibull wrote:
> Thanks!
>   

Feel free to post that patch, but also note that:
(1) We already have Dir.mktmpdir once you require 'tmpdir'
(2) Don't forget Windows and other systems which don't have file
descriptors.
Posted by Nobuyoshi Nakada (nobu)
on 25.04.2008 06:41
(Received via mailing list)
Hi,

At Fri, 25 Apr 2008 13:03:08 +0900,
Urabe Shyouhei wrote in [ruby-core:16584]:
> > Thanks!
> >   
> 
> Feel free to post that patch, but also note that:
> (1) We already have Dir.mktmpdir once you require 'tmpdir'
> (2) Don't forget Windows and other systems which don't have file 
> descriptors.

All systems have or emulate file descriptors and Shyouhei meant
the systems which mkdir(2) doesn't return a file descriptor.
I've not seen nor heared yet about such systems, mkdir(2) opens
the created directory togegher, though.