The implementation of the operations available to version 4 of the SFTP protocol.
F_CREATE_NEW | = | 0x00000000 |
F_CREATE_TRUNCATE | = | 0x00000001 |
F_OPEN_EXISTING | = | 0x00000002 |
F_OPEN_OR_CREATE | = | 0x00000003 |
F_TRUNCATE_EXISTING | = | 0x00000004 |
F_APPEND_DATA | = | 0x00000008 |
F_APPEND_DATA_ATOMIC | = | 0x00000010 |
F_TEXT_MODE | = | 0x00000020 |
F_READ_LOCK | = | 0x00000040 |
F_WRITE_LOCK | = | 0x00000080 |
F_DELETE_LOCK | = | 0x00000100 |
In version 4, fstat accepts a flags parameter. If flags is nil, it will default to returning all attributes. Otherwise, the flags parameter should be a bitwise combination of the F_xxx constants of Net::SFTP::Protocol::V_04::Attributes.
[ show source ]
# File lib/net/sftp/protocol/04/impl.rb, line 108 108: def fstat( id, handle, flags=nil ) 109: fstat_raw id, handle, convert_flags( flags ) 110: end
In version 4, lstat accepts a flags parameter. If flags is nil, it will default to returning all attributes. Otherwise, the flags parameter should be a bitwise combination of the F_xxx constants of Net::SFTP::Protocol::V_04::Attributes.
[ show source ]
# File lib/net/sftp/protocol/04/impl.rb, line 100 100: def lstat( id, filename, flags=nil ) 101: lstat_raw id, filename, convert_flags( flags ) 102: end
The open operation changed in version 4. This method keeps the same interface as previous versions, but changes how the parameters are interpreted and converted into a packet.
[ show source ]
# File lib/net/sftp/protocol/04/impl.rb, line 61 61: def open( id, path, flags, mode=0660 ) 62: sftp_flags, desired_access = case 63: when flags & IO::WRONLY != 0 then 64: [ F_CREATE_TRUNCATE, 65: ACE::F_WRITE_DATA | ACE::F_WRITE_ATTRIBUTES ] 66: when flags & IO::RDWR != 0 then 67: [ F_OPEN_OR_CREATE, 68: ACE::F_READ_DATA | ACE::F_READ_ATTRIBUTES | 69: ACE::F_WRITE_DATA | ACE::F_WRITE_ATTRIBUTES ] 70: when flags & IO::APPEND != 0 then 71: [ F_OPEN_OR_CREATE | F_APPEND_DATA, 72: ACE::F_WRITE_DATA | ACE::F_WRITE_ATTRIBUTES | 73: ACE::F_APPEND_DATA ] 74: else 75: [ F_OPEN_EXISTING, 76: ACE::F_READ_DATA | ACE::F_READ_ATTRIBUTES ] 77: end 78: 79: sftp_flags |= F_OPEN_OR_CREATE if flags & IO::CREAT != 0 80: sftp_flags |= F_TRUNCATE_EXISTING if flags & IO::TRUNC != 0 81: 82: attributes = @attr_factory.empty 83: attributes.permissions = mode 84: 85: open_raw id, path, desired_access, sftp_flags, attributes 86: end
In version 4, rename accepts a flags parameter. The valid flags are a combination of the following:
- FXP_RENAME_OVERWRITE (0x01)
- FXP_RENAME_ATOMIC (0x02)
- FXP_RENAME_NATIVE (0x04)
Please refer to the SSH2 specification for the description of these flags.
[ show source ]
# File lib/net/sftp/protocol/04/impl.rb, line 120 120: def rename( id, name, new_name, flags=0 ) 121: rename_raw id, name, new_name, flags 122: end
In version 4, stat accepts a flags parameter. If flags is nil, it will default to returning all attributes. Otherwise, the flags parameter should be a bitwise combination of the F_xxx constants of Net::SFTP::Protocol::V_04::Attributes.
[ show source ]
# File lib/net/sftp/protocol/04/impl.rb, line 92 92: def stat( id, filename, flags=nil ) 93: stat_raw id, filename, convert_flags( flags ) 94: end