net-sftp 1.1.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.rdoc +23 -0
- data/Manifest +55 -0
- data/README.rdoc +96 -0
- data/Rakefile +30 -0
- data/lib/net/sftp.rb +53 -38
- data/lib/net/sftp/constants.rb +187 -0
- data/lib/net/sftp/errors.rb +34 -20
- data/lib/net/sftp/operations/dir.rb +93 -0
- data/lib/net/sftp/operations/download.rb +364 -0
- data/lib/net/sftp/operations/file.rb +176 -0
- data/lib/net/sftp/operations/file_factory.rb +60 -0
- data/lib/net/sftp/operations/upload.rb +387 -0
- data/lib/net/sftp/packet.rb +21 -0
- data/lib/net/sftp/protocol.rb +32 -0
- data/lib/net/sftp/protocol/01/attributes.rb +265 -96
- data/lib/net/sftp/protocol/01/base.rb +268 -0
- data/lib/net/sftp/protocol/01/name.rb +43 -0
- data/lib/net/sftp/protocol/02/base.rb +31 -0
- data/lib/net/sftp/protocol/03/base.rb +35 -0
- data/lib/net/sftp/protocol/04/attributes.rb +120 -195
- data/lib/net/sftp/protocol/04/base.rb +94 -0
- data/lib/net/sftp/protocol/04/name.rb +67 -0
- data/lib/net/sftp/protocol/05/base.rb +66 -0
- data/lib/net/sftp/protocol/06/attributes.rb +107 -0
- data/lib/net/sftp/protocol/06/base.rb +63 -0
- data/lib/net/sftp/protocol/base.rb +50 -0
- data/lib/net/sftp/request.rb +91 -0
- data/lib/net/sftp/response.rb +76 -0
- data/lib/net/sftp/session.rb +914 -238
- data/lib/net/sftp/version.rb +14 -21
- data/net-sftp.gemspec +60 -0
- data/setup.rb +1331 -0
- data/test/common.rb +173 -0
- data/test/protocol/01/test_attributes.rb +97 -0
- data/test/protocol/01/test_base.rb +210 -0
- data/test/protocol/01/test_name.rb +27 -0
- data/test/protocol/02/test_base.rb +26 -0
- data/test/protocol/03/test_base.rb +27 -0
- data/test/protocol/04/test_attributes.rb +148 -0
- data/test/protocol/04/test_base.rb +74 -0
- data/test/protocol/04/test_name.rb +49 -0
- data/test/protocol/05/test_base.rb +62 -0
- data/test/protocol/06/test_attributes.rb +124 -0
- data/test/protocol/06/test_base.rb +51 -0
- data/test/protocol/test_base.rb +42 -0
- data/test/test_all.rb +3 -0
- data/test/test_dir.rb +47 -0
- data/test/test_download.rb +252 -0
- data/test/test_file.rb +159 -0
- data/test/test_file_factory.rb +48 -0
- data/test/test_packet.rb +9 -0
- data/test/test_protocol.rb +17 -0
- data/test/test_request.rb +71 -0
- data/test/test_response.rb +53 -0
- data/test/test_session.rb +741 -0
- data/test/test_upload.rb +219 -0
- metadata +59 -111
- data/doc/LICENSE-BSD +0 -27
- data/doc/LICENSE-GPL +0 -280
- data/doc/LICENSE-RUBY +0 -56
- data/doc/faq/faq.html +0 -298
- data/doc/faq/faq.rb +0 -154
- data/doc/faq/faq.yml +0 -183
- data/examples/asynchronous.rb +0 -57
- data/examples/get-put.rb +0 -45
- data/examples/sftp-open-uri.rb +0 -30
- data/examples/ssh-service.rb +0 -30
- data/examples/synchronous.rb +0 -131
- data/lib/net/sftp/operations/abstract.rb +0 -108
- data/lib/net/sftp/operations/close.rb +0 -31
- data/lib/net/sftp/operations/errors.rb +0 -76
- data/lib/net/sftp/operations/fsetstat.rb +0 -36
- data/lib/net/sftp/operations/fstat.rb +0 -32
- data/lib/net/sftp/operations/lstat.rb +0 -31
- data/lib/net/sftp/operations/mkdir.rb +0 -33
- data/lib/net/sftp/operations/open.rb +0 -32
- data/lib/net/sftp/operations/opendir.rb +0 -32
- data/lib/net/sftp/operations/read.rb +0 -88
- data/lib/net/sftp/operations/readdir.rb +0 -55
- data/lib/net/sftp/operations/realpath.rb +0 -37
- data/lib/net/sftp/operations/remove.rb +0 -31
- data/lib/net/sftp/operations/rename.rb +0 -32
- data/lib/net/sftp/operations/rmdir.rb +0 -31
- data/lib/net/sftp/operations/services.rb +0 -42
- data/lib/net/sftp/operations/setstat.rb +0 -33
- data/lib/net/sftp/operations/stat.rb +0 -31
- data/lib/net/sftp/operations/write.rb +0 -63
- data/lib/net/sftp/protocol/01/impl.rb +0 -251
- data/lib/net/sftp/protocol/01/packet-assistant.rb +0 -82
- data/lib/net/sftp/protocol/01/services.rb +0 -47
- data/lib/net/sftp/protocol/02/impl.rb +0 -39
- data/lib/net/sftp/protocol/02/packet-assistant.rb +0 -32
- data/lib/net/sftp/protocol/02/services.rb +0 -44
- data/lib/net/sftp/protocol/03/impl.rb +0 -42
- data/lib/net/sftp/protocol/03/packet-assistant.rb +0 -35
- data/lib/net/sftp/protocol/03/services.rb +0 -44
- data/lib/net/sftp/protocol/04/impl.rb +0 -86
- data/lib/net/sftp/protocol/04/packet-assistant.rb +0 -45
- data/lib/net/sftp/protocol/04/services.rb +0 -44
- data/lib/net/sftp/protocol/05/impl.rb +0 -90
- data/lib/net/sftp/protocol/05/packet-assistant.rb +0 -34
- data/lib/net/sftp/protocol/05/services.rb +0 -44
- data/lib/net/sftp/protocol/constants.rb +0 -60
- data/lib/net/sftp/protocol/driver.rb +0 -235
- data/lib/net/sftp/protocol/packet-assistant.rb +0 -84
- data/lib/net/sftp/protocol/services.rb +0 -55
- data/lib/uri/open-sftp.rb +0 -54
- data/lib/uri/sftp.rb +0 -42
- data/test/ALL-TESTS.rb +0 -23
- data/test/operations/tc_abstract.rb +0 -124
- data/test/operations/tc_close.rb +0 -40
- data/test/operations/tc_fsetstat.rb +0 -48
- data/test/operations/tc_fstat.rb +0 -40
- data/test/operations/tc_lstat.rb +0 -40
- data/test/operations/tc_mkdir.rb +0 -48
- data/test/operations/tc_open.rb +0 -42
- data/test/operations/tc_opendir.rb +0 -40
- data/test/operations/tc_read.rb +0 -103
- data/test/operations/tc_readdir.rb +0 -88
- data/test/operations/tc_realpath.rb +0 -54
- data/test/operations/tc_remove.rb +0 -40
- data/test/operations/tc_rmdir.rb +0 -40
- data/test/operations/tc_setstat.rb +0 -48
- data/test/operations/tc_stat.rb +0 -40
- data/test/operations/tc_write.rb +0 -91
- data/test/protocol/01/tc_attributes.rb +0 -138
- data/test/protocol/01/tc_impl.rb +0 -294
- data/test/protocol/01/tc_packet_assistant.rb +0 -81
- data/test/protocol/02/tc_impl.rb +0 -41
- data/test/protocol/02/tc_packet_assistant.rb +0 -31
- data/test/protocol/03/tc_impl.rb +0 -48
- data/test/protocol/03/tc_packet_assistant.rb +0 -34
- data/test/protocol/04/tc_attributes.rb +0 -174
- data/test/protocol/04/tc_impl.rb +0 -91
- data/test/protocol/04/tc_packet_assistant.rb +0 -38
- data/test/protocol/05/tc_impl.rb +0 -61
- data/test/protocol/05/tc_packet_assistant.rb +0 -32
- data/test/protocol/tc_driver.rb +0 -219
@@ -1,47 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# =============================================================================
|
3
|
-
# Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
|
4
|
-
# All rights reserved.
|
5
|
-
#
|
6
|
-
# This source file is distributed as part of the Net::SFTP Secure FTP Client
|
7
|
-
# library for Ruby. This file (and the library as a whole) may be used only as
|
8
|
-
# allowed by either the BSD license, or the Ruby license (or, by association
|
9
|
-
# with the Ruby license, the GPL). See the "doc" subdirectory of the Net::SFTP
|
10
|
-
# distribution for the texts of these licenses.
|
11
|
-
# -----------------------------------------------------------------------------
|
12
|
-
# net-sftp website: http://net-ssh.rubyforge.org/sftp
|
13
|
-
# project website : http://rubyforge.org/projects/net-ssh
|
14
|
-
# =============================================================================
|
15
|
-
#++
|
16
|
-
|
17
|
-
module Net ; module SFTP ; module Protocol ; module V_01
|
18
|
-
|
19
|
-
def register_services( container )
|
20
|
-
container.namespace_define :v_01 do |ns|
|
21
|
-
|
22
|
-
# The packet assistant to use for formatting SFTP packets.
|
23
|
-
ns.packet_assistant do |c,|
|
24
|
-
require 'net/sftp/protocol/01/packet-assistant'
|
25
|
-
PacketAssistant.new( c[:transport][:buffers],
|
26
|
-
c[:driver] )
|
27
|
-
end
|
28
|
-
|
29
|
-
# The attribute factory to use to obtain attribute object instances.
|
30
|
-
ns.attr_factory do |c,|
|
31
|
-
require 'net/sftp/protocol/01/attributes'
|
32
|
-
Attributes.init( c[:transport][:buffers] )
|
33
|
-
end
|
34
|
-
|
35
|
-
# The version implementation to use.
|
36
|
-
ns.impl do |c,|
|
37
|
-
require 'net/sftp/protocol/01/impl'
|
38
|
-
Impl.new( c[:transport][:buffers],
|
39
|
-
c[:driver], c[:packet_assistant],
|
40
|
-
c[:attr_factory] )
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
45
|
-
module_function :register_services
|
46
|
-
|
47
|
-
end ; end ; end ; end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# =============================================================================
|
3
|
-
# Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
|
4
|
-
# All rights reserved.
|
5
|
-
#
|
6
|
-
# This source file is distributed as part of the Net::SFTP Secure FTP Client
|
7
|
-
# library for Ruby. This file (and the library as a whole) may be used only as
|
8
|
-
# allowed by either the BSD license, or the Ruby license (or, by association
|
9
|
-
# with the Ruby license, the GPL). See the "doc" subdirectory of the Net::SFTP
|
10
|
-
# distribution for the texts of these licenses.
|
11
|
-
# -----------------------------------------------------------------------------
|
12
|
-
# net-sftp website: http://net-ssh.rubyforge.org/sftp
|
13
|
-
# project website : http://rubyforge.org/projects/net-ssh
|
14
|
-
# =============================================================================
|
15
|
-
#++
|
16
|
-
|
17
|
-
require 'net/sftp/protocol/01/impl'
|
18
|
-
|
19
|
-
module Net ; module SFTP ; module Protocol ; module V_02
|
20
|
-
|
21
|
-
# The implementation of the operations defined by version 2 of the SFTP
|
22
|
-
# protocol. This simply adds support for the RENAME operation, otherwise
|
23
|
-
# extending the version 1 implementation, unaltered.
|
24
|
-
class Impl < V_01::Impl
|
25
|
-
|
26
|
-
operation :rename
|
27
|
-
|
28
|
-
alias :rename_raw :rename
|
29
|
-
|
30
|
-
# This operation is special since a later version of the protocol adds
|
31
|
-
# support for flags. In this version, the flags parameter is ignored,
|
32
|
-
# but it exists for compatibility with later versions.
|
33
|
-
def rename( id, name, new_name, flags=nil )
|
34
|
-
rename_raw id, name, new_name
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
end ; end ; end ; end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# =============================================================================
|
3
|
-
# Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
|
4
|
-
# All rights reserved.
|
5
|
-
#
|
6
|
-
# This source file is distributed as part of the Net::SFTP Secure FTP Client
|
7
|
-
# library for Ruby. This file (and the library as a whole) may be used only as
|
8
|
-
# allowed by either the BSD license, or the Ruby license (or, by association
|
9
|
-
# with the Ruby license, the GPL). See the "doc" subdirectory of the Net::SFTP
|
10
|
-
# distribution for the texts of these licenses.
|
11
|
-
# -----------------------------------------------------------------------------
|
12
|
-
# net-sftp website: http://net-ssh.rubyforge.org/sftp
|
13
|
-
# project website : http://rubyforge.org/projects/net-ssh
|
14
|
-
# =============================================================================
|
15
|
-
#++
|
16
|
-
|
17
|
-
require 'net/sftp/protocol/01/packet-assistant'
|
18
|
-
|
19
|
-
module Net ; module SFTP ; module Protocol ; module V_02
|
20
|
-
|
21
|
-
# The packet assistant, used to format packets for version 2 of the SFTP
|
22
|
-
# protocol. This simply adds support for the RENAME packet:
|
23
|
-
#
|
24
|
-
# * rename( id, old, new )
|
25
|
-
class PacketAssistant < V_01::PacketAssistant
|
26
|
-
|
27
|
-
packet :rename, :string, # old name
|
28
|
-
:string # new name
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
end ; end ; end ; end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# =============================================================================
|
3
|
-
# Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
|
4
|
-
# All rights reserved.
|
5
|
-
#
|
6
|
-
# This source file is distributed as part of the Net::SFTP Secure FTP Client
|
7
|
-
# library for Ruby. This file (and the library as a whole) may be used only as
|
8
|
-
# allowed by either the BSD license, or the Ruby license (or, by association
|
9
|
-
# with the Ruby license, the GPL). See the "doc" subdirectory of the Net::SFTP
|
10
|
-
# distribution for the texts of these licenses.
|
11
|
-
# -----------------------------------------------------------------------------
|
12
|
-
# net-sftp website: http://net-ssh.rubyforge.org/sftp
|
13
|
-
# project website : http://rubyforge.org/projects/net-ssh
|
14
|
-
# =============================================================================
|
15
|
-
#++
|
16
|
-
|
17
|
-
module Net ; module SFTP ; module Protocol ; module V_02
|
18
|
-
|
19
|
-
def register_services( container )
|
20
|
-
container.namespace_define :v_02 do |ns|
|
21
|
-
|
22
|
-
ns.packet_assistant do |c,|
|
23
|
-
require 'net/sftp/protocol/02/packet-assistant'
|
24
|
-
PacketAssistant.new( c[:transport][:buffers],
|
25
|
-
c[:driver] )
|
26
|
-
end
|
27
|
-
|
28
|
-
ns.attr_factory do |c,|
|
29
|
-
require 'net/sftp/protocol/01/attributes'
|
30
|
-
V_01::Attributes.init( c[:transport][:buffers] )
|
31
|
-
end
|
32
|
-
|
33
|
-
ns.impl do |c,|
|
34
|
-
require 'net/sftp/protocol/02/impl'
|
35
|
-
Impl.new( c[:transport][:buffers],
|
36
|
-
c[:driver], c[:packet_assistant],
|
37
|
-
c[:attr_factory] )
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
end
|
42
|
-
module_function :register_services
|
43
|
-
|
44
|
-
end ; end ; end ; end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# =============================================================================
|
3
|
-
# Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
|
4
|
-
# All rights reserved.
|
5
|
-
#
|
6
|
-
# This source file is distributed as part of the Net::SFTP Secure FTP Client
|
7
|
-
# library for Ruby. This file (and the library as a whole) may be used only as
|
8
|
-
# allowed by either the BSD license, or the Ruby license (or, by association
|
9
|
-
# with the Ruby license, the GPL). See the "doc" subdirectory of the Net::SFTP
|
10
|
-
# distribution for the texts of these licenses.
|
11
|
-
# -----------------------------------------------------------------------------
|
12
|
-
# net-sftp website: http://net-ssh.rubyforge.org/sftp
|
13
|
-
# project website : http://rubyforge.org/projects/net-ssh
|
14
|
-
# =============================================================================
|
15
|
-
#++
|
16
|
-
|
17
|
-
require 'net/sftp/protocol/02/impl'
|
18
|
-
|
19
|
-
module Net ; module SFTP ; module Protocol ; module V_03
|
20
|
-
|
21
|
-
# The implementation of the operations for version 3 of the SFTP protocol.
|
22
|
-
# This adds support for the readlink and symlink operations.
|
23
|
-
class Impl < V_02::Impl
|
24
|
-
|
25
|
-
operation :readlink,
|
26
|
-
:symlink
|
27
|
-
|
28
|
-
# The #status message changed in this version. It adds +message+ and
|
29
|
-
# +language+ fields, so the callback now receives +driver+, +id+, +code+,
|
30
|
-
# +message+, and +language+ as parameters.
|
31
|
-
def do_status( channel, content )
|
32
|
-
return unless has_on_status?
|
33
|
-
id = content.read_long
|
34
|
-
code = content.read_long
|
35
|
-
message = content.read_string
|
36
|
-
language = content.read_string
|
37
|
-
call_on_status( driver, id, code, message, language )
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
end ; end ; end ; end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# =============================================================================
|
3
|
-
# Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
|
4
|
-
# All rights reserved.
|
5
|
-
#
|
6
|
-
# This source file is distributed as part of the Net::SFTP Secure FTP Client
|
7
|
-
# library for Ruby. This file (and the library as a whole) may be used only as
|
8
|
-
# allowed by either the BSD license, or the Ruby license (or, by association
|
9
|
-
# with the Ruby license, the GPL). See the "doc" subdirectory of the Net::SFTP
|
10
|
-
# distribution for the texts of these licenses.
|
11
|
-
# -----------------------------------------------------------------------------
|
12
|
-
# net-sftp website: http://net-ssh.rubyforge.org/sftp
|
13
|
-
# project website : http://rubyforge.org/projects/net-ssh
|
14
|
-
# =============================================================================
|
15
|
-
#++
|
16
|
-
|
17
|
-
require 'net/sftp/protocol/02/packet-assistant'
|
18
|
-
|
19
|
-
module Net ; module SFTP ; module Protocol ; module V_03
|
20
|
-
|
21
|
-
# The packet assistant which formats packets for version 3 of the SFTP
|
22
|
-
# protocol. This adds support for the readlink and symlink packets:
|
23
|
-
#
|
24
|
-
# * readlink( id, path )
|
25
|
-
# * symlink( id, link, target )
|
26
|
-
class PacketAssistant < V_02::PacketAssistant
|
27
|
-
|
28
|
-
packet :readlink, :string # path
|
29
|
-
|
30
|
-
packet :symlink, :string, # link-path
|
31
|
-
:string # target-path
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
end ; end ; end ; end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# =============================================================================
|
3
|
-
# Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
|
4
|
-
# All rights reserved.
|
5
|
-
#
|
6
|
-
# This source file is distributed as part of the Net::SFTP Secure FTP Client
|
7
|
-
# library for Ruby. This file (and the library as a whole) may be used only as
|
8
|
-
# allowed by either the BSD license, or the Ruby license (or, by association
|
9
|
-
# with the Ruby license, the GPL). See the "doc" subdirectory of the Net::SFTP
|
10
|
-
# distribution for the texts of these licenses.
|
11
|
-
# -----------------------------------------------------------------------------
|
12
|
-
# net-sftp website: http://net-ssh.rubyforge.org/sftp
|
13
|
-
# project website : http://rubyforge.org/projects/net-ssh
|
14
|
-
# =============================================================================
|
15
|
-
#++
|
16
|
-
|
17
|
-
module Net ; module SFTP ; module Protocol ; module V_03
|
18
|
-
|
19
|
-
def register_services( container )
|
20
|
-
container.namespace_define :v_03 do |ns|
|
21
|
-
|
22
|
-
ns.packet_assistant do |c,|
|
23
|
-
require 'net/sftp/protocol/03/packet-assistant'
|
24
|
-
PacketAssistant.new( c[:transport][:buffers],
|
25
|
-
c[:driver] )
|
26
|
-
end
|
27
|
-
|
28
|
-
ns.attr_factory do |c,|
|
29
|
-
require 'net/sftp/protocol/01/attributes'
|
30
|
-
V_01::Attributes.init( c[:transport][:buffers] )
|
31
|
-
end
|
32
|
-
|
33
|
-
ns.impl do |c,|
|
34
|
-
require 'net/sftp/protocol/03/impl'
|
35
|
-
Impl.new( c[:transport][:buffers],
|
36
|
-
c[:driver], c[:packet_assistant],
|
37
|
-
c[:attr_factory] )
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
end
|
42
|
-
module_function :register_services
|
43
|
-
|
44
|
-
end ; end ; end ; end
|
@@ -1,86 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# =============================================================================
|
3
|
-
# Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
|
4
|
-
# All rights reserved.
|
5
|
-
#
|
6
|
-
# This source file is distributed as part of the Net::SFTP Secure FTP Client
|
7
|
-
# library for Ruby. This file (and the library as a whole) may be used only as
|
8
|
-
# allowed by either the BSD license, or the Ruby license (or, by association
|
9
|
-
# with the Ruby license, the GPL). See the "doc" subdirectory of the Net::SFTP
|
10
|
-
# distribution for the texts of these licenses.
|
11
|
-
# -----------------------------------------------------------------------------
|
12
|
-
# net-sftp website: http://net-ssh.rubyforge.org/sftp
|
13
|
-
# project website : http://rubyforge.org/projects/net-ssh
|
14
|
-
# =============================================================================
|
15
|
-
#++
|
16
|
-
|
17
|
-
require 'net/sftp/protocol/03/impl'
|
18
|
-
|
19
|
-
module Net ; module SFTP ; module Protocol ; module V_04
|
20
|
-
|
21
|
-
# The implementation of the operations available to version 4 of the SFTP
|
22
|
-
# protocol.
|
23
|
-
class Impl < V_03::Impl
|
24
|
-
|
25
|
-
# In version 4, stat accepts a flags parameter. If flags is +nil+, it
|
26
|
-
# will default to returning all attributes. Otherwise, the flags parameter
|
27
|
-
# should be a bitwise combination of the F_xxx constants of
|
28
|
-
# Net::SFTP::Protocol::V_04::Attributes.
|
29
|
-
def stat( id, filename, flags=nil )
|
30
|
-
stat_raw id, filename, convert_flags( flags )
|
31
|
-
end
|
32
|
-
|
33
|
-
# In version 4, lstat accepts a flags parameter. If flags is +nil+, it
|
34
|
-
# will default to returning all attributes. Otherwise, the flags parameter
|
35
|
-
# should be a bitwise combination of the F_xxx constants of
|
36
|
-
# Net::SFTP::Protocol::V_04::Attributes.
|
37
|
-
def lstat( id, filename, flags=nil )
|
38
|
-
lstat_raw id, filename, convert_flags( flags )
|
39
|
-
end
|
40
|
-
|
41
|
-
# In version 4, fstat accepts a flags parameter. If flags is +nil+, it
|
42
|
-
# will default to returning all attributes. Otherwise, the flags parameter
|
43
|
-
# should be a bitwise combination of the F_xxx constants of
|
44
|
-
# Net::SFTP::Protocol::V_04::Attributes.
|
45
|
-
def fstat( id, handle, flags=nil )
|
46
|
-
fstat_raw id, handle, convert_flags( flags )
|
47
|
-
end
|
48
|
-
|
49
|
-
# In version 4, rename accepts a flags parameter. The valid flags are a
|
50
|
-
# combination of the following:
|
51
|
-
#
|
52
|
-
# * FXP_RENAME_OVERWRITE (0x01)
|
53
|
-
# * FXP_RENAME_ATOMIC (0x02)
|
54
|
-
# * FXP_RENAME_NATIVE (0x04)
|
55
|
-
#
|
56
|
-
# Please refer to the SSH2 specification for the description of these flags.
|
57
|
-
def rename( id, name, new_name, flags=0 )
|
58
|
-
rename_raw id, name, new_name, flags
|
59
|
-
end
|
60
|
-
|
61
|
-
# A convenience method for converting the (stat) flags parameter into a
|
62
|
-
# value acceptible to the SFTP protocol.
|
63
|
-
def convert_flags( flags )
|
64
|
-
return 0x800001FD if flags.nil?
|
65
|
-
flags
|
66
|
-
end
|
67
|
-
private :convert_flags
|
68
|
-
|
69
|
-
# Used internally to handle +name+ packets. The +on_name+ callback is
|
70
|
-
# invoked, if registered, with the driver, id, and array of items. The v4
|
71
|
-
# version of this method sets the 'longname' member of the Name object to
|
72
|
-
# +nil+ (it is not used in this version).
|
73
|
-
def do_name( channel, content )
|
74
|
-
return unless has_on_name?
|
75
|
-
id = content.read_long
|
76
|
-
items = []
|
77
|
-
content.read_long.times do
|
78
|
-
items.push( Name.new( content.read_string, nil,
|
79
|
-
@attr_factory.from_buffer( content ) ) )
|
80
|
-
end
|
81
|
-
call_on_name( driver, id, items )
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
end ; end ; end ; end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# =============================================================================
|
3
|
-
# Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
|
4
|
-
# All rights reserved.
|
5
|
-
#
|
6
|
-
# This source file is distributed as part of the Net::SFTP Secure FTP Client
|
7
|
-
# library for Ruby. This file (and the library as a whole) may be used only as
|
8
|
-
# allowed by either the BSD license, or the Ruby license (or, by association
|
9
|
-
# with the Ruby license, the GPL). See the "doc" subdirectory of the Net::SFTP
|
10
|
-
# distribution for the texts of these licenses.
|
11
|
-
# -----------------------------------------------------------------------------
|
12
|
-
# net-sftp website: http://net-ssh.rubyforge.org/sftp
|
13
|
-
# project website : http://rubyforge.org/projects/net-ssh
|
14
|
-
# =============================================================================
|
15
|
-
#++
|
16
|
-
|
17
|
-
require 'net/sftp/protocol/03/packet-assistant'
|
18
|
-
|
19
|
-
module Net ; module SFTP ; module Protocol ; module V_04
|
20
|
-
|
21
|
-
# Version 4 of the SFTP protocol changed the number of parameters to several
|
22
|
-
# different packet types:
|
23
|
-
#
|
24
|
-
# * rename( id, old, new, flags )
|
25
|
-
# * stat( id, path, flags )
|
26
|
-
# * lstat( id, path, flags )
|
27
|
-
# * fstat( id, handle, flags )
|
28
|
-
class PacketAssistant < V_03::PacketAssistant
|
29
|
-
|
30
|
-
packet :rename, :string, # old name
|
31
|
-
:string, # new name
|
32
|
-
:long # flags
|
33
|
-
|
34
|
-
packet :stat, :string, # path
|
35
|
-
:long # flags
|
36
|
-
|
37
|
-
packet :lstat, :string, # path
|
38
|
-
:long # flags
|
39
|
-
|
40
|
-
packet :fstat, :string, # handle
|
41
|
-
:long # flags
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
end ; end ; end ; end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# =============================================================================
|
3
|
-
# Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
|
4
|
-
# All rights reserved.
|
5
|
-
#
|
6
|
-
# This source file is distributed as part of the Net::SFTP Secure FTP Client
|
7
|
-
# library for Ruby. This file (and the library as a whole) may be used only as
|
8
|
-
# allowed by either the BSD license, or the Ruby license (or, by association
|
9
|
-
# with the Ruby license, the GPL). See the "doc" subdirectory of the Net::SFTP
|
10
|
-
# distribution for the texts of these licenses.
|
11
|
-
# -----------------------------------------------------------------------------
|
12
|
-
# net-sftp website: http://net-ssh.rubyforge.org/sftp
|
13
|
-
# project website : http://rubyforge.org/projects/net-ssh
|
14
|
-
# =============================================================================
|
15
|
-
#++
|
16
|
-
|
17
|
-
module Net ; module SFTP ; module Protocol ; module V_04
|
18
|
-
|
19
|
-
def register_services( container )
|
20
|
-
container.namespace_define :v_04 do |ns|
|
21
|
-
|
22
|
-
ns.packet_assistant do |c,|
|
23
|
-
require 'net/sftp/protocol/04/packet-assistant'
|
24
|
-
PacketAssistant.new( c[:transport][:buffers],
|
25
|
-
c[:driver] )
|
26
|
-
end
|
27
|
-
|
28
|
-
ns.attr_factory do |c,|
|
29
|
-
require 'net/sftp/protocol/04/attributes'
|
30
|
-
Attributes.init( c[:transport][:buffers] )
|
31
|
-
end
|
32
|
-
|
33
|
-
ns.impl do |c,|
|
34
|
-
require 'net/sftp/protocol/04/impl'
|
35
|
-
Impl.new( c[:transport][:buffers],
|
36
|
-
c[:driver], c[:packet_assistant],
|
37
|
-
c[:attr_factory] )
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
end
|
42
|
-
module_function :register_services
|
43
|
-
|
44
|
-
end ; end ; end ; end
|