mkdir -p

M

Martin DeMello

Shouldn't Dir.mkdir support something akin to unix's mkdir -p ? i.e.,
Dir.mkdir("a/b/c") should make a, then a/b, then a/b/c if the right
option is passed in.

martin
 
H

Hal Fulton

Martin said:
Shouldn't Dir.mkdir support something akin to unix's mkdir -p ? i.e.,
Dir.mkdir("a/b/c") should make a, then a/b, then a/b/c if the right
option is passed in.

This is in FileUtils or something. I forget exactly where.


Hal
 
Y

Yukihiro Matsumoto

Hi,

In message "mkdir -p"

|Shouldn't Dir.mkdir support something akin to unix's mkdir -p ? i.e.,
|Dir.mkdir("a/b/c") should make a, then a/b, then a/b/c if the right
|option is passed in.

FileUtils.mkdir_p(path)

matz.
 
M

Martin DeMello

Yukihiro Matsumoto said:
Hi,

In message "mkdir -p"

|Shouldn't Dir.mkdir support something akin to unix's mkdir -p ? i.e.,
|Dir.mkdir("a/b/c") should make a, then a/b, then a/b/c if the right
|option is passed in.

FileUtils.mkdir_p(path)

Thanks. Why doesn't FileUtils mix this into Dir?

martin
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: mkdir -p"

|> FileUtils.mkdir_p(path)
|
|Thanks. Why doesn't FileUtils mix this into Dir?

Dir methods are one to one relationship to the system calls.
FileUtils are more abstract/higher level/uniformed way to operate on
files/directories.

matz.
 
M

Martin DeMello

Yukihiro Matsumoto said:
Hi,

In message "Re: mkdir -p"

|> FileUtils.mkdir_p(path)
|
|Thanks. Why doesn't FileUtils mix this into Dir?

Dir methods are one to one relationship to the system calls.
FileUtils are more abstract/higher level/uniformed way to operate on
files/directories.

This feels wrong to me - it goes back to the "closed classes" paradigm
of adding a module simply to store a bunch of high level functions. I
don't know if it's just me, but I'm *always* taken aback when something
I'm looking for turns up in FileUtils rather than attached to the object
it acts upon.

On the other hand, perhaps mkdir doesn't belong as part of Dir - perhaps
we should consider renaming FileUtils to FileSystem and aliasing it so
as not to break old code - FileSystem.mkdir just reads more rubyishly to
me.

martin
 
M

martinankerl at eml dot cc

|Thanks. Why doesn't FileUtils mix this into Dir?
Dir methods are one to one relationship to the system calls.
FileUtils are more abstract/higher level/uniformed way to operate on
files/directories.

This is a technical explanation, but not a reason...
I don't see a reason why this technical detail should not be hidden from
a Ruby user.

Martin
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: mkdir -p"

|> Dir methods are one to one relationship to the system calls.
|> FileUtils are more abstract/higher level/uniformed way to operate on
|> files/directories.
|
|This is a technical explanation, but not a reason...

It's a technical explanation and a design policy.

matz.
 
J

Jeff Mitchell

--- Yukihiro Matsumoto said:
Hi,

In message "Re: mkdir -p"

|> Dir methods are one to one relationship to the system calls.
|> FileUtils are more abstract/higher level/uniformed way to operate on
|> files/directories.
|
|This is a technical explanation, but not a reason...

It's a technical explanation and a design policy.

matz.

It is important to keep high-level libraries high-level, and
low-level libraries low-level. When the two mix you get
a sort of pollution.

For example, OpenGL doesn't specify a windowing system, and
from the other side, applications generally don't manipulate
kernel space. These are extreme examples, but the concept
applies equally to Dir/FileUtils.






__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/
 
M

Minero Aoki

Hi,

In mail "Re: mkdir -p"

One reason is that FileUtils's methods have different
characteristics from File/Dir.

* FileUtils methods accepts a path or a list of pathes.
* FileUtils methods accepts options.

Dir.mkdir_p accepts a list of pathes, but Dir.mkdir does not
accept a list... it's inconsistent.

On the other hand, perhaps mkdir doesn't belong as part of Dir - perhaps
we should consider renaming FileUtils to FileSystem and aliasing it so
as not to break old code - FileSystem.mkdir just reads more rubyishly to
me.

I don't think so, FileUtils is just a module.
FileSystem object is different beast.

Regards,
Minero Aoki
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
EmeliaBryc

Latest Threads

Top