From 83a6963286128e8cd22c7d7c8905acb493aa18d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= <stephane.adjemian@univ-lemans.fr> Date: Thu, 26 Nov 2015 20:51:48 +0100 Subject: [PATCH] Rewrote get_file_extension. --- matlab/get_file_extension.m | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/matlab/get_file_extension.m b/matlab/get_file_extension.m index 56c140d838..d922b36ac5 100644 --- a/matlab/get_file_extension.m +++ b/matlab/get_file_extension.m @@ -11,7 +11,7 @@ function ext = get_file_extension(file) % REMARKS % If the provided file name has no extension, the routine will return an empty array. -% Copyright (C) 2013 Dynare Team +% Copyright (C) 2013-2015 Dynare Team % % This file is part of Dynare. % @@ -28,15 +28,9 @@ function ext = get_file_extension(file) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see <http://www.gnu.org/licenses/>. -% Clean-up path -file = strrep(file, '../', ''); -file = strrep(file, './', ''); +[dir, fname, ext] = fileparts(file); -remain = file; -while ~isempty(remain) - [ext, remain] = strtok(remain,'.'); -end - -if strcmp(ext,file) - ext = []; +if ~isempty(ext) + % Removes the leading dot. + ext = ext(2:end); end \ No newline at end of file -- GitLab