Directory within directorry?


#1

Hi All,

I want to create a directory, i used command:

Dir.mkdir("#{RAILS_ROOT}/public/public1/public2/public3")

but its not working. don’t know the reason.
So i tried for:

Dir.mkdir("#{RAILS_ROOT}/public/public1")
Dir.mkdir("#{RAILS_ROOT}/public/public1/public2")
Dir.mkdir("#{RAILS_ROOT}/public/public1/public2/public3")

and it worked.

Can the code be minimized?
Please suggest me, can the three lined code be made one lined?

Thanks
Saurabh


#2

Hi,

2009/3/18 Saurabh P. removed_email_address@domain.invalid:

Dir.mkdir("#{RAILS_ROOT}/public/public1/public2")
Dir.mkdir("#{RAILS_ROOT}/public/public1/public2/public3")

and it worked.

Can the code be minimized?
Please suggest me, can the three lined code be made one lined?

require ‘fileutils’
FileUtils.mkdir_p “#{RAILS_ROOT}/public/public1/public2/public3”

Regards,

Park H.


#3

Saurabh P. wrote:

I want to create a directory, i used command:
Dir.mkdir("#{RAILS_ROOT}/public/public1/public2/public3")
Can the code be minimized?

require ‘fileutils’
FileUtils::mkpath("#{RAILS_ROOT}/public/public1/public2/public3")