/** * @constructor FTP * * ### Synopsis * * var ftp = new FTP(host, username, password); * * Creates a new FTP connection. * * @param {string} host - remote host to connect to. * @param {string} username - username on remote host to login as. * @param {string} password - password for username on remote host. * * ### Notes * * This constructor throws an error if the connection or authentication fails. */ function FTP(host, username, password) { _ftp.init(); this.handle = _ftp.connect(host+':21'); if (!this.handle) { error('connect failed'); } var loggedIn = _ftp.login(this.handle, username, password); if (!loggedIn) { error('login failed'); } this.cwd = _ftp.getcwd(this.handle); this.systemType = _ftp.systemType(this.handle); }
chdir: function(path) { var ret = _ftp.chdir(this.handle, path); this.cwd = _ftp.getcwd(this.handle); return ret; },