SFTP file exists? lazarus / 43-Android ---------------------------------------------------------------------- xinyiman · 2023-04-11 19:50 Hi in FTP/SFTP client components, is there a command to find out if a file exists in the final destination? ---------------------------------------------------------------------- KodeZwerg · 2023-04-11 20:47 I would invoke a "LIST" command to get content (folders and files) and compare if whatever you wanted is in that list. ---------------------------------------------------------------------- xinyiman · 2023-04-12 06:31 I know it can be done like this, I was just wondering if there was a function for that. So you don't have to reinvent the wheel. ---------------------------------------------------------------------- MarkMLl · 2023-04-12 07:49 Check the relevant RFCs. The de-facto standard FTP client has the rstatus command, but a great deal depends on the extent to which that's directly supported by the protocol as distinct from causing execution of a separate binary (i.e. in this case the stat command) on the server. MarkMLl ---------------------------------------------------------------------- rvk · 2023-04-12 08:02 Quote from: xinyiman on April 11, 2023, 09:50:08 pmin FTP/SFTP client components, is there a command ... So, what commands are you referring to exactly? It would depend on the component if such command is implemented. ---------------------------------------------------------------------- xinyiman · 2023-04-12 08:17 Component is jSFTPClient ---------------------------------------------------------------------- rvk · 2023-04-12 09:29 Quote from: xinyiman on April 12, 2023, 10:17:04 amComponent is jSFTPClient I'm not familiar with that one. If it's this one https://github.com/jmpessoa/lazandroidmodulewizard/bl ob/master/android_bridges/sftpclient.pas then there doesn't seem to be a simple function to just check if a file exists, so you would have to write your own. You could use the .ListFiles() for that. (I can't even see any df, stat or other options in that source.) (If it's another component you should also mention the source.) ---------------------------------------------------------------------- xinyiman · 2023-04-12 10:13 The component is that, since there is jmpessoa on the forum I wanted to know from him if there was an alternative. ---------------------------------------------------------------------- Remy Lebeau · 2023-04-12 15:57 Quote from: KodeZwerg on April 11, 2023, 10:47:15 pmI would invoke a "LIST" command to get content (folders and files) and compare if whatever you wanted is in that list. If you are just checking for an item's existence, you could use the NLST command instead, which returns a list of just the names of every item in the directory and no details about them, whereas the LIST (and MLSD) command(s) return full details about the items. Another option would be to use the STAT, SIZE, MDTM, or MLST command (if the server supports them) to directly query the specific item of interest, and see if the command succeeds or fails. ---------------------------------------------------------------------- rvk · 2023-04-12 16:04 The issue is not how this is done with the (s)ftp protocol but how this can be done with the jSFTPClient component. ---------------------------------------------------------------------- jmpessoa · 2023-04-12 18:51 QuoteThe issue is not how this is done with the (s)ftp protocol but how this can be done with the jSFTPClient component.... Yes,  [LAMW] jSFTPClient component is far from complete.... Alternatively someone can use any pure pascal (FCL?) SFTPCliente (or Indy...) ---------------------------------------------------------------------- Mongkey · 2023-04-21 03:41 Quote from: KodeZwerg on April 11, 2023, 10:47:15 pmI would invoke a "LIST" command to get content (folders and files) and compare if whatever you wanted is in that list. This 1 is alternative for checking file exist over ftp server, i did this for several years, it quite good.