DELETE Delete file(s) on an SFTP server. Syntax: DELETE(H, FILENAME) Description: DELETE(H, FILENAME) deletes file(s) on the server. Examples: delete(h, filename) See also: SFTP Authors: Joan Pau Beltran <joanpau.beltran@socib.cat>
0001 function delete(h, filename) 0002 %DELETE Delete file(s) on an SFTP server. 0003 % 0004 % Syntax: 0005 % DELETE(H, FILENAME) 0006 % 0007 % Description: 0008 % DELETE(H, FILENAME) deletes file(s) on the server. 0009 % 0010 % Examples: 0011 % delete(h, filename) 0012 % 0013 % See also: 0014 % SFTP 0015 % 0016 % Authors: 0017 % Joan Pau Beltran <joanpau.beltran@socib.cat> 0018 0019 % Copyright (C) 2014-2016 0020 % ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears 0021 % <http://www.socib.es> 0022 % 0023 % This program is free software: you can redistribute it and/or modify 0024 % it under the terms of the GNU General Public License as published by 0025 % the Free Software Foundation, either version 3 of the License, or 0026 % (at your option) any later version. 0027 % 0028 % This program is distributed in the hope that it will be useful, 0029 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0030 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0031 % GNU General Public License for more details. 0032 % 0033 % You should have received a copy of the GNU General Public License 0034 % along with this program. If not, see <http://www.gnu.org/licenses/>. 0035 0036 try 0037 atts = mexsftp('lsfile', h.sftp_handle, filename); 0038 catch exception 0039 if ~strcmp(exception.identifier, 'sftp:lsfile:ListError') 0040 rethrow(exception); 0041 end 0042 atts = mexsftp('lsglob', h.sftp_handle, filename); 0043 end 0044 0045 filesep_index = find(filename == '/', 1, 'last'); 0046 if isempty(filesep_index) 0047 prefix = ''; 0048 else 0049 prefix = [filename(1:filesep_index-1) '/']; 0050 end 0051 0052 for i = 1:numel(atts) 0053 mexsftp('delfile', h.sftp_handle, [prefix atts(i).name]); 0054 end 0055 0056 end