Class: ExFTP

Inherits:
Net::FTP
  • Object
show all
Defined in:
lib/carrierwave/storage/ftp/ex_ftp.rb

Instance Method Summary collapse

Instance Method Details

#mkdir_p(dir) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/carrierwave/storage/ftp/ex_ftp.rb', line 4

def mkdir_p(dir)
  parts = dir.split("/")
  if parts.first == "~"
    growing_path = ""
  else
    growing_path = "/"
  end
  for part in parts
    next if part == ""
    if growing_path == ""
      growing_path = part
    else
      growing_path = File.join(growing_path, part)
    end
    begin
      mkdir(growing_path)
      chdir(growing_path)
    rescue Net::FTPPermError, Net::FTPTempError => e
    end
  end
end