mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/net/ftp.rb (get): new method.
* lib/net/ftp.rb (putt): ditto. * lib/net/ftp.rb (binary): ditto. * lib/net/ftp.rb (binary=): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9620b20227
commit
8e346d8cb1
2 changed files with 35 additions and 6 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
Wed Jul 3 14:26:40 2002 Sean Chittenden <sean@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/net/ftp.rb (get): new method.
|
||||||
|
|
||||||
|
* lib/net/ftp.rb (putt): ditto.
|
||||||
|
|
||||||
|
* lib/net/ftp.rb (binary): ditto.
|
||||||
|
|
||||||
|
* lib/net/ftp.rb (binary=): ditto.
|
||||||
|
|
||||||
Wed Jul 3 13:57:53 2002 Sean Chittenden <sean@ruby-lang.org>
|
Wed Jul 3 13:57:53 2002 Sean Chittenden <sean@ruby-lang.org>
|
||||||
|
|
||||||
* lib/net/ftp.rb (getbinaryfile): the second argument (localfile)
|
* lib/net/ftp.rb (getbinaryfile): the second argument (localfile)
|
||||||
|
|
|
@ -28,7 +28,7 @@ module Net
|
||||||
|
|
||||||
DEFAULT_BLOCKSIZE = 4096
|
DEFAULT_BLOCKSIZE = 4096
|
||||||
|
|
||||||
attr_accessor :passive, :return_code, :debug_mode, :resume
|
attr_accessor :binary, :passive, :return_code, :debug_mode, :resume
|
||||||
attr_reader :welcome, :lastresp
|
attr_reader :welcome, :lastresp
|
||||||
|
|
||||||
def FTP.open(host, user = nil, passwd = nil, acct = nil)
|
def FTP.open(host, user = nil, passwd = nil, acct = nil)
|
||||||
|
@ -37,6 +37,7 @@ module Net
|
||||||
|
|
||||||
def initialize(host = nil, user = nil, passwd = nil, acct = nil)
|
def initialize(host = nil, user = nil, passwd = nil, acct = nil)
|
||||||
super()
|
super()
|
||||||
|
@binary = true
|
||||||
@passive = false
|
@passive = false
|
||||||
@return_code = "\n"
|
@return_code = "\n"
|
||||||
@debug_mode = false
|
@debug_mode = false
|
||||||
|
@ -48,7 +49,7 @@ module Net
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def open_socket(host, port)
|
def open_socket(host, port)
|
||||||
if defined? SOCKSsocket and ENV["SOCKS_SERVER"]
|
if defined? SOCKSsocket and ENV["SOCKS_SERVER"]
|
||||||
@passive = true
|
@passive = true
|
||||||
|
@ -326,7 +327,7 @@ module Net
|
||||||
voidresp
|
voidresp
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def getbinaryfile(remotefile, localfile = File.basename(remotefile),
|
def getbinaryfile(remotefile, localfile = File.basename(remotefile),
|
||||||
blocksize = DEFAULT_BLOCKSIZE, &block)
|
blocksize = DEFAULT_BLOCKSIZE, &block)
|
||||||
if @resume
|
if @resume
|
||||||
|
@ -359,8 +360,17 @@ module Net
|
||||||
f.close
|
f.close
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get(localfile, remotefile = File.basename(localfile),
|
||||||
|
blocksize = DEFAULT_BLOCKSIZE, &block)
|
||||||
|
unless @binary
|
||||||
|
gettextfile(localfile, remotefile, &block)
|
||||||
|
else
|
||||||
|
getbinaryfile(localfile, remotefile, blocksize, &block)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def putbinaryfile(localfile, remotefile,
|
def putbinaryfile(localfile, remotefile = File.basename(localfile),
|
||||||
blocksize = DEFAULT_BLOCKSIZE, &block)
|
blocksize = DEFAULT_BLOCKSIZE, &block)
|
||||||
if @resume
|
if @resume
|
||||||
rest_offset = size(remotefile)
|
rest_offset = size(remotefile)
|
||||||
|
@ -376,7 +386,7 @@ module Net
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def puttextfile(localfile, remotefile, &block)
|
def puttextfile(localfile, remotefile = File.basename(localfile), &block)
|
||||||
f = open(localfile)
|
f = open(localfile)
|
||||||
begin
|
begin
|
||||||
storlines("STOR " + remotefile, f, &block)
|
storlines("STOR " + remotefile, f, &block)
|
||||||
|
@ -384,7 +394,16 @@ module Net
|
||||||
f.close
|
f.close
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def put(localfile, remotefile = File.basename(localfile),
|
||||||
|
blocksize = DEFAULT_BLOCKSIZE, &block)
|
||||||
|
unless @binary
|
||||||
|
puttextfile(localfile, remotefile, &block)
|
||||||
|
else
|
||||||
|
putbinaryfile(localfile, remotefile, blocksize, &block)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def acct(account)
|
def acct(account)
|
||||||
cmd = "ACCT " + account
|
cmd = "ACCT " + account
|
||||||
voidcmd(cmd)
|
voidcmd(cmd)
|
||||||
|
|
Loading…
Reference in a new issue