Re: [JSch-users] SftpATTRS.exists() and Exception handling.
Status: Alpha
Brought to you by:
ymnk
|
From: <ym...@jc...> - 2007-02-22 01:55:15
|
Hi, +-From: "Jochen boutens" <j_g...@ho...> -- |_Date: Wed, 21 Feb 2007 13:09:51 +0000 ______________ | |What is the best way to check if a file exists on an SFTP server? |I'm using the libs to synchronize files and I need to check weather or not |the remote file exists. |Am I supposed to lsstat(path) the file/dir? And an exception will be |returned if the object doesn't exist? The sftp protocol[1] has defined SSH_FXP_STAT and SSH_FXP_LSTAT, and jsch has defined "stat(path)" and "lstat(path)". As you have expected, they will throw an exception if they can not get the stat info. # stat(path) will follow symbolic links on the server, but lstat(path) # will not. |My second question is about the development of the libraries. The libs |currently only throw one exception. That exception has included error-code, which is from sftp-server and defined in sftp protocol[1] at "9.1 Status Response". [1] http://tools.ietf.org/id/draft-ietf-secsh-filexfer-13.txt Sincerely, -- Atsuhiko Yamanaka JCraft,Inc. 1-14-20 HONCHO AOBA-KU, SENDAI, MIYAGI 980-0014 Japan. Tel +81-22-723-2150 +1-415-578-3454 Fax +81-22-224-8773 Skype callto://jcraft/ |