annotate private/EDB1strpend.m @ 18:2d5f50205527 jabuilder_int tip

Escape the trailing backslash as well
author Chris Cannam
date Tue, 30 Sep 2014 16:23:00 +0100
parents 90220f7249fc
children
rev   line source
tp@0 1 function Filenameout = EDB1strpend(Filenamein,striptext)
tp@0 2 % EDB1strpend - Removes a specified ending from a filename.
tp@0 3 % First, any extension is removed.
tp@0 4 %
tp@0 5 % Input parameters:
tp@0 6 % Filenemain A text string with the filename
tp@0 7 % stripext A text string with the ending that should
tp@0 8 % be removed.
tp@0 9 %
tp@0 10 % Output parameters:
tp@0 11 % Filenameout A text string with the extension-stripped filename
tp@0 12 %
tp@0 13 % Uses no special functions
tp@0 14 %
tp@0 15 % ----------------------------------------------------------------------------------------------
tp@0 16 % This file is part of the Edge Diffraction Toolbox by Peter Svensson.
tp@0 17 %
tp@0 18 % The Edge Diffraction Toolbox is free software: you can redistribute it and/or modify
tp@0 19 % it under the terms of the GNU General Public License as published by the Free Software
tp@0 20 % Foundation, either version 3 of the License, or (at your option) any later version.
tp@0 21 %
tp@0 22 % The Edge Diffraction Toolbox is distributed in the hope that it will be useful,
tp@0 23 % but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
tp@0 24 % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
tp@0 25 %
tp@0 26 % You should have received a copy of the GNU General Public License along with the
tp@0 27 % Edge Diffraction Toolbox. If not, see <http://www.gnu.org/licenses/>.
tp@0 28 % ----------------------------------------------------------------------------------------------
tp@0 29 % Peter Svensson (svensson@iet.ntnu.no) 20100812
tp@0 30
tp@0 31 [Filepath,Filenameout,temp1] = fileparts(Filenamein);
tp@0 32
tp@0 33 if ~isempty(Filepath)
tp@0 34 Filenameout = [Filepath,filesep,Filenameout];
tp@0 35 end
tp@0 36
tp@0 37 str1 = lower(Filenameout);
tp@0 38 str2 = lower(striptext);
tp@0 39 n1 = length(str1);
tp@0 40 n2 = length(str2);
tp@0 41 if n1 >= n2
tp@0 42 if str1(n1-n2+1:n1) == str2
tp@0 43 Filenameout = Filenameout(1:n1-n2);
tp@0 44 end
tp@0 45 end