lib/rio/ftp/fs.rb in rio-0.5.1 vs lib/rio/ftp/fs.rb in rio-0.6.0
- old
+ new
@@ -1,8 +1,8 @@
#--
# ===========================================================================
-# Copyright (c) 2005-2012 Christopher Kleckner
+# Copyright (c) 2005-2017 Christopher Kleckner
# All rights reserved
#
# This file is part of the Rio library for ruby.
#
# Rio is free software; you can redistribute it and/or modify
@@ -61,35 +61,31 @@
include RIO::FS::Str
def pwd() conn.pwd end
def getwd()
- #p "GETWD self.pwd=#{self.pwd}"
self.pwd
end
def cwd()
remote_wd = self.pwd.sub(%r{/*$},'/')
remote_rel = remote_wd.sub(/^#{self.remote_root}/,'')
wduri = uri.clone
wduri.path = remote_rel
wduri.to_s
end
def remote_path(url)
- #p "remote_path: url=#{url.inspect}"
uri = Alt::URI.parse(url)
path = uri.path
wd = self.pwd
- #p "remote_path remote_root=#{self.remote_root} path=#{path} wd=#{wd}"
rpth = if path.start_with?('/')
path
else
self.remote_wd + path
end
rpth
end
def chdir(url,&block)
- #p "ftp::fs chdir url=#{url}"
if block_given?
wd = conn.pwd
conn.chdir(remote_path(url))
begin
rtn = yield remote_wd
@@ -100,15 +96,11 @@
else
conn.chdir(remote_path(url))
end
end
def mkdir(url)
- #p "ftp/fs/mkdir: url=#{url}"
rp = remote_path(url)
- #p "ftp/fs/mkdir: rp=#{rp}"
- #wd = conn.pwd
- #p "ftp/fs/mkdir: wd=#{wd}"
conn.mkdir(rp)
end
def mv(src_url,dst_url)
conn.rename(remote_path(src_url),remote_path(dst_url))
end
@@ -130,13 +122,11 @@
def put(localfile,remote_file = ::File.basename(localfile))
conn.put(localfile,remote_path(remote_file))
end
def get_ftype(url)
- #p "get_ftype(#{url})"
pth = remote_path(url)
- #p "URL=#{url},PTH=#{pth}"
ftype = nil
begin
conn.mdtm(pth)
ftype = :file
rescue Net::FTPPermError
@@ -163,11 +153,10 @@
end
def symlink?(url)
false
end
def mkpath(url)
- #p "mkpath: #{url.inspect}"
pathparts = url.split('/')
pathparts.shift if pathparts[0] == ""
pathparts[0] = '/' + pathparts[0] if url.start_with?('/')
pth = ""
pathparts.each do |part|
@@ -180,10 +169,9 @@
end
private
def _rment(url)
- #p "_rment(#{url})"
ftype = get_ftype(url)
case ftype
when :file
rm(url)
when :dir