# HG changeset patch # User Carlo de Falco # Date 1342133864 -7200 # Node ID 5af491abbed981b071515e71ab3fcc961422f3e7 # Parent e027f98403c39b488fbec3d48f3fb447d9b53326 remove redundant private function absolute_pathname * scripts/pkg/pkg.m: remove calls to absolute_pathname * scripts/pkg/private/build.m: remove call to absolute_pathname * scripts/pkg/module.mk: remove absolute_pathname * scripts/pkg/private/absolute_pathname.m: remove file diff --git a/scripts/pkg/module.mk b/scripts/pkg/module.mk --- a/scripts/pkg/module.mk +++ b/scripts/pkg/module.mk @@ -1,7 +1,6 @@ FCN_FILE_DIRS += pkg pkg_PRIVATE_FCN_FILES = \ - pkg/private/absolute_pathname.m \ pkg/private/build.m \ pkg/private/configure_make.m \ pkg/private/copy_files.m \ diff --git a/scripts/pkg/pkg.m b/scripts/pkg/pkg.m --- a/scripts/pkg/pkg.m +++ b/scripts/pkg/pkg.m @@ -421,50 +421,46 @@ global_packages = archprefix; elseif (length (files) >= 1 && nargout <= 2 && ischar (files{1})) prefix = files{1}; - try - prefix = absolute_pathname (prefix); - catch + if (! exist (prefix, "dir")) [status, msg, msgid] = mkdir (prefix); if (status == 0) error("cannot create prefix %s: %s", prefix, msg); endif warning ("creating the directory %s\n", prefix); - prefix = absolute_pathname (prefix); - end_try_catch - prefix = absolute_pathname (prefix); - local_packages = prefix; + endif + local_packages = prefix = canonicalize_filename (prefix); user_prefix = true; if (length (files) >= 2 && ischar (files{2})) archprefix = files{2}; - try - archprefix = absolute_pathname (archprefix); - catch + if (! exist (archprefix, "dir")) [status, msg, msgid] = mkdir (archprefix); if (status == 0) error("cannot create archprefix %s: %s", archprefix, msg); endif warning ("creating the directory %s\n", archprefix); - archprefix = absolute_pathname (archprefix); - end_try_catch - global_packages = archprefix; + global_packages = archprefix = canonicalize_file_name (archprefix); + endif endif else error ("you must specify a prefix directory, or request an output argument"); endif - + case "local_list" if (length (files) == 0 && nargout == 0) disp (local_list); elseif (length (files) == 0 && nargout == 1) local_packages = local_list; elseif (length (files) == 1 && nargout == 0 && ischar (files{1})) - try - local_list = absolute_pathname (files{1}); - catch - ## Force file to be created - fclose (fopen (files{1}, "wt")); - local_list = absolute_pathname (files{1}); - end_try_catch + local_list = files{1}; + if (! exist (local_list, "file")) + try + ## Force file to be created + fclose (fopen (local_list, "wt")); + catch + error ("cannot create file %s", local_list); + end_try_catch + endif + local_list = canonicalize_file_name (local_list); else error ("you must specify a local_list file, or request an output argument"); endif @@ -475,13 +471,16 @@ elseif (length (files) == 0 && nargout == 1) local_packages = global_list; elseif (length (files) == 1 && nargout == 0 && ischar (files{1})) - try - global_list = absolute_pathname (files{1}); - catch - ## Force file to be created - fclose (fopen (files{1}, "wt")); - global_list = absolute_pathname (files{1}); - end_try_catch + global_list = files{1}; + if (! exist (global_list, "file")) + try + ## Force file to be created + fclose (fopen (files{1}, "wt")); + catch + error ("cannot create file %s", global_list); + end_try_catch + endif + global_list = canonicalize_file_name (global_list); else error ("you must specify a global_list file, or request an output argument"); endif diff --git a/scripts/pkg/private/absolute_pathname.m b/scripts/pkg/private/absolute_pathname.m deleted file mode 100644 --- a/scripts/pkg/private/absolute_pathname.m +++ /dev/null @@ -1,33 +0,0 @@ -## Copyright (C) 2005-2012 Søren Hauberg -## Copyright (C) 2010 VZLU Prague, a.s. -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## . - -## -*- texinfo -*- -## @deftypefn {Function File} address@hidden =} absolute_pathname (@var{pth}) -## Undocumented internal function. -## @end deftypefn - -function pth = absolute_pathname (pth) - [status, msg, msgid] = fileattrib (pth); - if (status != 1) - error ("could not find the file or path %s", pth); - else - pth = msg.Name; - endif -endfunction - diff --git a/scripts/pkg/private/build.m b/scripts/pkg/private/build.m --- a/scripts/pkg/private/build.m +++ b/scripts/pkg/private/build.m @@ -34,7 +34,10 @@ error ("could not create installation directory: %s", msg); endif endif - builddir = absolute_pathname (builddir); + [builddir, status] = canonicalize_file_name (builddir); + if (! status) + error ("cannot find directory %s", builddir); + endif installdir = fullfile (builddir, "install"); if (! exist (installdir, "dir")) [status, msg] = mkdir (installdir);