Skip to content

Commit

Permalink
* lib/net/ftp.rb (return_code): obsolete.
Browse files Browse the repository at this point in the history
* lib/net/ftp.rb (last_response_code): new method. lastresp is now
alias to last_response_code.
* lib/net/ftp.rb (last_response): new method.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
shugo committed Jul 30, 2003
1 parent 59b2d55 commit 1358ec5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 26 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Thu Jul 31 00:17:19 2003 Shugo Maeda <shugo@ruby-lang.org>

* lib/net/ftp.rb (return_code): obsolete.

* lib/net/ftp.rb (last_response_code): new method. lastresp is now
alias to last_response_code.

* lib/net/ftp.rb (last_response): new method.

Wed Jul 30 22:35:19 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>

* lib/mkmf.rb (dir_config): allow multiple directories separated
Expand Down
54 changes: 28 additions & 26 deletions lib/net/ftp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ class FTP
# When +true+, the connection is in passive mode. Default: false.
attr_accessor :passive

# The ASCII code used to separate lines.
attr_accessor :return_code

# When +true+, all traffic to and from the server is written
# to +$stdout+. Default: +false+.
attr_accessor :debug_mode
Expand All @@ -81,8 +78,12 @@ class FTP
# The server's welcome message.
attr_reader :welcome

# The server's last response code.
attr_reader :last_response_code
alias lastresp last_response_code

# The server's last response.
attr_reader :lastresp
attr_reader :last_response

#
# A synonym for +FTP.new+, but with a mandatory host parameter.
Expand Down Expand Up @@ -112,7 +113,6 @@ def initialize(host = nil, user = nil, passwd = nil, acct = nil)
super()
@binary = true
@passive = false
@return_code = "\n"
@debug_mode = false
@resume = false
if host
Expand All @@ -123,6 +123,15 @@ def initialize(host = nil, user = nil, passwd = nil, acct = nil)
end
end

def return_code
$stderr.puts("warning: Net::FTP#return_code is obsolete and do nothing")
return "\n"
end

def return_code=(s)
$stderr.puts("warning: Net::FTP#return_code= is obsolete and do nothing")
end

def open_socket(host, port)
if defined? SOCKSsocket and ENV["SOCKS_SERVER"]
@passive = true
Expand Down Expand Up @@ -181,12 +190,7 @@ def putline(line)

def getline
line = @sock.readline # if get EOF, raise EOFError
if line[-2, 2] == CRLF
line = line[0 .. -3]
elsif line[-1] == ?\r or
line[-1] == ?\n
line = line[0 .. -2]
end
line.sub!(/(\r\n|\n|\r)\z/n, "")
if @debug_mode
print "get: ", sanitize(line), "\n"
end
Expand All @@ -209,18 +213,17 @@ def getmultiline
private :getmultiline

def getresp
resp = getmultiline
@lastresp = resp[0, 3]
c = resp[0]
case c
when ?1, ?2, ?3
return resp
when ?4
raise FTPTempError, resp
when ?5
raise FTPPermError, resp
@last_response = getmultiline
@last_response_code = @last_response[0, 3]
case @last_response_code
when /\A[123]/
return @last_response
when /\A4/
raise FTPTempError, @last_response
when /\A5/
raise FTPPermError, @last_response
else
raise FTPProtoError, resp
raise FTPProtoError, @last_response
end
end
private :getresp
Expand All @@ -234,7 +237,7 @@ def voidresp
private :voidresp

#
# WRITEME or make private
# Sends a command and returns the response.
#
def sendcmd(cmd)
synchronize do
Expand All @@ -244,7 +247,7 @@ def sendcmd(cmd)
end

#
# WRITEME or make private
# Sends a command and expect a response beginning with '2'.
#
def voidcmd(cmd)
synchronize do
Expand Down Expand Up @@ -494,8 +497,7 @@ def gettextfile(remotefile, localfile = File.basename(remotefile), &block) # :yi
f = open(localfile, "w")
begin
retrlines("RETR " + remotefile) do |line|
line = line + @return_code
f.write(line)
f.puts(line)
yield(line) if block
end
ensure
Expand Down

0 comments on commit 1358ec5

Please sign in to comment.