# File lib/net/sftp/session.rb, line 164
    def open_handle( path, flags=IO::RDONLY, mode=0660 )
      if String === flags
        flags = case flags
          when "r" then IO::RDONLY
          when "r+" then IO:RDWR
          when "w" then IO::WRONLY | IO::CREAT | IO::TRUNC
          when "w+" then IO::RDWR | IO::CREAT | IO::TRUNC
          when "a" then IO::APPEND | IO::CREAT
          when "a+" then IO::APPEND | IO::CREAT
          else IO::RDONLY
        end
      end

      handle = self.open( path, flags, mode )
      if block_given?
        begin
          yield handle
        ensure
          close_handle( handle )
        end
      else
        return handle
      end
    end