+ copyfile (primitive)
+ fileparts (primitive)
+ isdir manages matrix of strings as input argument
+ + basename (primitive)
+ + pathconvert (primitive)
Dynamic link:
=============
* bug 4795 fixed - CallScilab.h renamed call_scilab.h
+* bug 4798 fixed - pathconvert macro should be rewritten as a primitive (many times used and not faster).
+
* bug 4807 fixed - strsubst does not check if second argument is a valid patter where fourth argument is 'r'.
* bug 4810 fixed - gsort does not manage sparse vectors as sort.
clear root_tlbx;
clear etc_tlbx;
clear pathmacros;
-clear pathconvert;
// ====================================================================
end
setenv("VERSION",getversion());
-clear pathconvert; //remove the local variable
-
// Protect variable previously defined ================================
predef("all");
// load temporary functions needed by all others
// =============================================================================
-
-load("SCI/modules/fileio/macros/pathconvert.bin");
-
if WITH_HELPTOOLS then
load(SCI+"/modules/helptools/macros/add_module_help_chapter.bin");
load(SCI+"/modules/helptools/macros/add_help_chapter.bin");
src/c/splitpath.c \
src/c/movefile.c \
src/c/expandPathVariable.c \
+src/c/basename.c \
+src/c/pathconvert.c \
src/c/copyfile_others.c
GATEWAY_SOURCES = \
sci_gateway/c/sci_copyfile.c \
sci_gateway/c/sci_fileparts.c \
sci_gateway/c/sci_movefile.c \
+sci_gateway/c/sci_basename.c \
+sci_gateway/c/sci_pathconvert.c \
sci_gateway/c/sci_isfile.c
//Load functions libraries
// =============================================================================
-clear pathconvert;
load('SCI/modules/fileio/macros/lib');
// Add help chapter
>
</File>
<File
+ RelativePath=".\src\c\basename.c"
+ >
+ </File>
+ <File
RelativePath=".\src\c\cluni0.c"
>
</File>
>
</File>
<File
+ RelativePath=".\src\c\pathconvert.c"
+ >
+ </File>
+ <File
RelativePath=".\src\c\readline.c"
>
</File>
>
</File>
<File
+ RelativePath=".\sci_gateway\c\sci_basename.c"
+ >
+ </File>
+ <File
RelativePath=".\sci_gateway\c\sci_chdir.c"
>
</File>
>
</File>
<File
+ RelativePath=".\sci_gateway\c\sci_pathconvert.c"
+ >
+ </File>
+ <File
RelativePath=".\sci_gateway\c\sci_pathsep.c"
>
</File>
>
</File>
<File
+ RelativePath=".\src\c\basename.h"
+ >
+ </File>
+ <File
RelativePath=".\includes\cluni0.h"
>
</File>
>
</File>
<File
+ RelativePath=".\src\c\pathconvert.h"
+ >
+ </File>
+ <File
RelativePath=".\includes\removedir.h"
>
</File>
<literal>HOME</literal>, <literal>SCI</literal> or <literal>~</literal>
are expanded using environment variables.</para>
- <para>Note that <literal>basename(files,%f)</literal> can give erroneous
- results if pathnames given in files do not follow the convention given by
- the <literal>MSDOS</literal> variable.</para>
-
- <para>basename uses fileparts to strip directory and suffix from
- filenames.</para>
</refsection>
<refsection>
FILEIO_IMPEXP int sci_isfile(char *fname,unsigned long fname_len);
FILEIO_IMPEXP int sci_fileparts(char *fname,unsigned long fname_len);
FILEIO_IMPEXP int sci_movefile(char *fname,unsigned long fname_len);
+FILEIO_IMPEXP int sci_basename(char *fname,unsigned long fname_len);
+FILEIO_IMPEXP int sci_pathconvert(char *fname,unsigned long fname_len);
/*--------------------------------------------------------------------------*/
#endif /* __GW_FILEIO_H__ */
/*--------------------------------------------------------------------------*/
#define __SPLIPATH_H__
#include <wchar.h>
+#include "BOOL.h"
#include "dynlib_fileio.h"
/**
* Parts of file name and path
* @param[in] filename or path
+* @param[in] BOOL expand filename
* @param[out] drive
* @param[out] directory
* @param[out] filename
* @param[out] file extension
*/
-FILEIO_IMPEXP void splitpath(const char* path, char* drv, char* dir, char* name, char* ext);
+FILEIO_IMPEXP void splitpath(const char* path, BOOL bExpand, char* drv, char* dir, char* name, char* ext);
/**
* Parts of file name and path (Wide string)
* @param[in] filename or path
+* @param[in] BOOL expand filename
* @param[out] drive
* @param[out] directory
* @param[out] filename
* @param[out] file extension
*/
-FILEIO_IMPEXP void splitpathW(const wchar_t* path, wchar_t* drv, wchar_t* dir, wchar_t* name, wchar_t* ext);
+FILEIO_IMPEXP void splitpathW(const wchar_t* path, BOOL bExpand, wchar_t* drv, wchar_t* dir, wchar_t* name, wchar_t* ext);
#endif /* __SPLIPATH_H__ */
/*--------------------------------------------------------------------------*/
+++ /dev/null
-// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) ENPC
-// Copyright (C) - 2009 - DIGITEO - Allan CORNET
-//
-// This file must be used under the terms of the CeCILL.
-// This source file is licensed as described in the file COPYING, which
-// you should have received as part of this distribution. The terms
-// are also available at
-// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
-
-function [files]= basename(files,flag,flagexpand)
-// strip directory and suffix from filenames
-// if flag == %t files are first converted
-// according to MSDOS
-
- [lhs,rhs]=argn(0);
-
- if (files == []) | (files == '') then
- return
- end
-
- if type(files) <> 10 then
- error(999, msprintf(gettext("%s: Wrong type for input argument #%d: String array expected.\n"),"basename",1) );
- end
-
- if rhs <= 1 then flag = %t ; end
- if rhs <= 2 then flagexpand = %t ; end
-
- if (type(flag) <> 4) then
- error(999, msprintf(gettext("%s: Wrong type for input argument #%d: A boolean expected.\n"),"basename",2));
- end
-
- if (type(flagexpand) <> 4) then
- error(999, msprintf(gettext("%s: Wrong type for input argument #%d: A boolean expected.\n"),"basename",3));
- end
-
- if flag == %t then
- files = pathconvert(files,%f,flagexpand);
- end
-
- sep = filesep();
-
- for i=1:size(files,'*')
- if files(i) <> '' then
- files(i) = fileparts(files(i),'fname');
- end
- end
-endfunction
-
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) INRIA
+// Copyright (C) DIGITEO - 2009 - Allan CORNET
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
function path=cd(path)
- if argn(2)==1 then
+ if (argn(2) == 1) then
if type(path) <> 10 then
error(999,msprintf(_("%s: Wrong type for input argument #%d: A string expected.\n"),'cd',1));
end
- path=stripblanks(path)
- if or(path==['PWD' 'SCIHOME']) then path=evstr(path),end
- if MSDOS then
- if or(path==['WSCI']) then path=evstr(path),end
+
+ if size(path,'*') <> 1 then
+ error(999,msprintf(_("%s: Wrong size for input argument #%d: A string expected.\n"),'cd',1));
+ end
+
+ path = stripblanks(path);
+
+ if (path == 'PWD') then
+ path = evstr(path);
end
- if or(path==['SCI' '~' 'TMPDIR' 'home' ]) path=path+'/',end
if or(path==['/' '\' '..']) then
- chdir(path)
+ chdir(path);
else
if ~isdir(path) then
error(msprintf(gettext("%s: Cannot go to directory %s\n"),'cd',path),998);
end
- chdir(path)
+ chdir(path);
end
else
chdir(home);
end
- path=pwd();
+ path = pwd();
endfunction
warning(msprintf(gettext("%s: Options ignored.\n"),"ls"));
end
- if or(path==['PWD' 'SCIHOME']) then path=evstr(path),end
-
- if MSDOS then
- if or(path==['WSCI']) then path=evstr(path),end
- end
- if or(path==['SCI' '~' 'TMPDIR' 'home' ]) path=path+'/',end
+ if or(path=='PWD') then path=evstr(path),end
// dir returns names without the dirname
files = listfiles(path);
+++ /dev/null
-// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) ENPC
-// Copyright (C) DIGITEO - 2009 - Allan CORNET
-//
-// This file must be used under the terms of the CeCILL.
-// This source file is licensed as described in the file COPYING, which
-// you should have received as part of this distribution. The terms
-// are also available at
-// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
-
-function paths = pathconvert(paths, flagtrail, flagexpand, str)
-// convert a path from dos style to unix style
-// using cygwin conventions i.e x: -> /cygdrive/x
-// if flagtrail is true then a trailing / or \ is added
-// if flagexpand is true then SCI, HOME, ~ ,TMPDIR are expanded
-// str gives the target style 'u' or 'w'
-
- [lhs,rhs] = argn(0);
-
- unix_sep = '/';
- dos_sep = '\';
-
- sci = SCI;
-
- if rhs <= 1 then flagtrail = %t ;end
- if rhs <= 2 then flagexpand = %t ; end
- if rhs <= 3 then
- if MSDOS then
- str = 'w';
- else
- str = 'u';
- end
- end
-
- if str == 'w' then
- sep = dos_sep;
- if isdef('WSCI') then sci = WSCI;end
- else
- sep = unix_sep;
- end
-
- if type(paths) <> 10 then
- error(999,msprintf(_("%s: Wrong type for input argument #%d: A string expected.\n"),'pathconvert',1));
- end
-
- if type(flagtrail) <> 4 then
- error(999,msprintf(_("%s: Wrong type for input argument #%d: A boolean expected.\n"),'pathconvert',2));
- end
-
- if size(flagtrail,'*') <> 1 then
- error(999,msprintf(_("%s: Wrong size for input argument #%d: A boolean expected.\n"),'pathconvert',2));
- end
-
- if type(flagexpand) <> 4 then
- error(999,msprintf(_("%s: Wrong type for input argument #%d: A boolean expected.\n"),'pathconvert',3));
- end
-
- if size(flagexpand,'*') <> 1 then
- error(999,msprintf(_("%s: Wrong size for input argument #%d: A boolean expected.\n"),'pathconvert',3));
- end
-
- if type(str) <> 10 then
- error(999,msprintf(_("%s: Wrong type for input argument #%d: A string expected.\n"),'pathconvert',4));
- end
-
- if size(str,'*') <> 1 then
- error(999,msprintf(_("%s: Wrong size for input argument #%d: A string expected.\n"),'pathconvert',4));
- end
-
- if ( (str <> 'w') & (str <> 'u') ) then
- error(999,msprintf(_("%s: Wrong value for input argument #%d: ''w'' or ''u'' expected.\n"),'pathconvert',4));
- end
-
- // strip leading and trailink blanks
- paths = stripblanks(paths);
-
- // \ and / conversion
- if str == 'w' then
- paths = strsubst(paths, unix_sep, dos_sep);
- else
- paths = strsubst(paths, dos_sep, unix_sep);
- end
-
- // add a trailing / or \ at the end
-
- if flagtrail then
- for i = 1:size(paths,'*')
- path = paths(i);
- len = length(path);
- if len > 0 then
- if part(path, length(path))<> sep then
- paths(i) = paths(i) + sep;
- end
- end
- end
- else
- for i = 1:size(paths,'*')
- path = paths(i);
- len = length(path);
- if (len > 0) & (path <> sep) then
- if part(path, length(path)) == sep then
- paths(i) = part(paths(i), 1:length(path)-1);
- end
- end
- end
- end
-
- // expand HOME, SCI and ~ , TMPDIR
-
- is_expanded = %f;
-
- if flagexpand then
- for i = 1:size(paths,'*')
- path = paths(i);
- if part(path, 1:4) == 'SCI' + sep then
- is_expanded = %t ;
- paths(i) = sci + part(path,4:length(path));
- elseif part(path, 1:2) == '~' + sep then
- is_expanded = %t ;
- paths(i) = getenv('HOME','/home/') + part(path,2:length(path));
- elseif part(path, 1:5) == 'HOME' + sep then
- is_expanded = %t;
- paths(i) = getenv('HOME','/home/')+part(path,5:length(path));
- elseif part(path, 1:7) == 'TMPDIR' + sep then
- is_expanded = %t;
- paths(i) = TMPDIR + part(path, 7:length(path));
- end
- end
- end
-
- // \ and / conversion again
- if is_expanded then
- if str == 'w' then
- paths = strsubst(paths, unix_sep, dos_sep);
- else
- paths = strsubst(paths, dos_sep, unix_sep);
- end
- end
-
- // check for \cygdrive\xx\
- if str == 'w' then
- // convert \cygdrive\xx to xx:
- for i=1:size(paths,'*')
- path=paths(i);
- if part(path,1:10) == '\cygdrive\' then
- // get the letter name
- k = strindex(path,'\');
- if length(k) <= 2 then
- paths(i) = part(path,11:length(path))+':' ;
- else
- paths(i) = part(path,11:k(3)-1) + ':' + part(path,k(3):length(path));
- end
- end
- end
- else
- // convert xx: to /cygdrive/xx
- for i = 1:size(paths,'*')
- path = paths(i);
- k = strindex(path,'/');
- if k == [] then
- if part(path,length(path)) == ':' then
- paths(i) = '/cygdrive/' + part(path,1:length(path)-1) + sep;
- end
- elseif k(1) > 1 then
- if part(path,k(1)-1) == ':' then
- paths(i) = '/cygdrive/' + part(path,1:k(1)-2)+ part(path,k(1):length(path));
- end
- end
- end
- end
-
-endfunction
{sci_copyfile,"copyfile"},
{sci_isfile,"isfile"},
{sci_fileparts,"fileparts"},
- {sci_movefile,"movefile"}
+ {sci_movefile,"movefile"},
+ {sci_basename,"basename"},
+ {sci_pathconvert,"pathconvert"}
};
/*--------------------------------------------------------------------------*/
int gw_fileio(void)
--- /dev/null
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2009 - DIGITEO - Allan CORNET
+*
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution. The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+/*--------------------------------------------------------------------------*/
+#include "gw_fileio.h"
+#include "stack-c.h"
+#include "MALLOC.h"
+#include "localization.h"
+#include "api_common.h"
+#include "api_string.h"
+#include "api_double.h"
+#include "api_boolean.h"
+#include "basename.h"
+#include "Scierror.h"
+#include "freeArrayOfString.h"
+/*--------------------------------------------------------------------------*/
+int sci_basename(char *fname,unsigned long fname_len)
+{
+ BOOL flag = TRUE; /* default */
+ BOOL flagexpand = TRUE; /* default */
+
+ int *piAddressVarOne = NULL;
+ wchar_t **pStVarOne = NULL;
+ int *lenStVarOne = NULL;
+ int m1 = 0, n1 = 0;
+
+ wchar_t **pStResult = NULL;
+
+ int i = 0;
+
+ /* Check Input & Output parameters */
+ CheckRhs(1,3);
+ CheckLhs(1,1);
+
+ if (Rhs > 2)
+ {
+ int *piAddressVarThree = NULL;
+ int *piData = NULL;
+ int m3 = 0, n3 = 0;
+
+ getVarAddressFromPosition(3, &piAddressVarThree);
+ if (getVarType(piAddressVarThree) != sci_boolean)
+ {
+ Scierror(999,_("%s: Wrong type for input argument #%d: A boolean expected.\n"), fname, 3);
+ return 0;
+ }
+
+ getVarDimension(piAddressVarThree, &m3, &n3);
+
+ if ( (m3 != n3) && (n3 != 1) )
+ {
+ Scierror(999,_("%s: Wrong size for input argument #%d: A boolean expected.\n"), fname, 3);
+ return 0;
+ }
+
+ getMatrixOfBoolean(piAddressVarThree, &m3, &n3, &piData);
+ flagexpand = piData[0];
+
+ }
+
+ if (Rhs > 1)
+ {
+ int *piAddressVarTwo = NULL;
+ int *piData = NULL;
+ int m2 = 0, n2 = 0;
+
+ getVarAddressFromPosition(2, &piAddressVarTwo);
+ if (getVarType(piAddressVarTwo) != sci_boolean)
+ {
+ Scierror(999,_("%s: Wrong type for input argument #%d: A boolean expected.\n"), fname, 2);
+ return 0;
+ }
+
+ getVarDimension(piAddressVarTwo, &m2, &n2);
+
+ if ( (m2 != n2) && (n2 != 1) )
+ {
+ Scierror(999,_("%s: Wrong size for input argument #%d: A boolean expected.\n"), fname, 2);
+ return 0;
+ }
+
+ getMatrixOfBoolean(piAddressVarTwo, &m2, &n2, &piData);
+ flag = piData[0];
+ }
+
+ getVarAddressFromPosition(1, &piAddressVarOne);
+
+ if (getVarType(piAddressVarOne) == sci_matrix)
+ {
+ getVarDimension(piAddressVarOne, &m1, &n1);
+ if ( (m1 == n1) && (m1 == 0) )
+ {
+ createMatrixOfDouble(Rhs + 1, m1, n1, NULL);
+ LhsVar(1) = Rhs + 1;
+ C2F(putlhsvar)();
+ }
+ else
+ {
+ Scierror(999,_("%s: Wrong type for input argument #%d: String array expected.\n"), fname, 1);
+ }
+ }
+ else if (getVarType(piAddressVarOne) == sci_strings)
+ {
+ getVarDimension(piAddressVarOne, &m1, &n1);
+
+ lenStVarOne = (int*)MALLOC(sizeof(int) * (m1 * n1));
+ if (lenStVarOne == NULL)
+ {
+ Scierror(999,_("%s : Memory allocation error.\n"),fname);
+ return 0;
+ }
+
+ pStVarOne = (wchar_t**)MALLOC(sizeof(wchar_t*) * (m1 * n1));
+ if (pStVarOne == NULL)
+ {
+ if (lenStVarOne) {FREE(lenStVarOne); lenStVarOne = NULL;}
+ Scierror(999,_("%s : Memory allocation error.\n"),fname);
+ return 0;
+ }
+
+ getMatrixOfWideString(piAddressVarOne, &m1, &n1, lenStVarOne, pStVarOne);
+ pStResult = (wchar_t**)MALLOC(sizeof(wchar_t*) * (m1 * n1));
+
+ if (pStResult == NULL)
+ {
+ if (lenStVarOne) {FREE(lenStVarOne); lenStVarOne = NULL;}
+ Scierror(999,_("%s : Memory allocation error.\n"),fname);
+ return 0;
+ }
+
+ for (i=0;i< m1 * n1; i++)
+ {
+ pStResult[i] = basenameW(pStVarOne[i], flagexpand);
+ }
+
+ createMatrixOfWideString(Rhs + 1, m1, n1, pStResult);
+ LhsVar(1) = Rhs + 1;
+ C2F(putlhsvar)();
+
+ if (lenStVarOne) {FREE(lenStVarOne); lenStVarOne = NULL;}
+ freeArrayOfWideString(pStResult, m1 * n1);
+ }
+ else
+ {
+ Scierror(999,_("%s: Wrong type for input argument #%d: String array expected.\n"), fname, 1);
+ }
+ return 0;
+}
+/*--------------------------------------------------------------------------*/
wchar_t* wcext = MALLOC(sizeof(wchar_t*) * ((int)wcslen(wcFullFilename) + 1));
wcfilename = MALLOC(sizeof(wchar_t*) * ((int)wcslen(wcFullFilename) + 1));
- splitpathW(wcFullFilename, wcdrv, wcdir, wcname, wcext);
+ splitpathW(wcFullFilename, FALSE, wcdrv, wcdir, wcname, wcext);
wcscpy(wcfilename, wcname);
wcscat(wcfilename, wcext);
return 0;
}
- splitpathW(pStVarOne, drv, dir, name, ext);
+ splitpathW(pStVarOne, FALSE, drv, dir, name, ext);
if (pStVarTwo) /* Rhs == 2 */
{
wchar_t* wcext = MALLOC(sizeof(wchar_t*) * ((int)wcslen(wcFullFilename) + 1));
wcfilename = MALLOC(sizeof(wchar_t*) * ((int)wcslen(wcFullFilename) + 1));
- splitpathW(wcFullFilename, wcdrv, wcdir, wcname, wcext);
+ splitpathW(wcFullFilename, FALSE, wcdrv, wcdir, wcname, wcext);
wcscpy(wcfilename, wcname);
wcscat(wcfilename, wcext);
--- /dev/null
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2009 - DIGITEO - Allan CORNET
+*
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution. The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+/*--------------------------------------------------------------------------*/
+#include "gw_fileio.h"
+#include "stack-c.h"
+#include "MALLOC.h"
+#include "localization.h"
+#include "api_common.h"
+#include "api_string.h"
+#include "api_double.h"
+#include "api_boolean.h"
+#include "Scierror.h"
+#include "pathconvert.h"
+#include "freeArrayOfString.h"
+/*--------------------------------------------------------------------------*/
+int sci_pathconvert(char *fname,unsigned long fname_len)
+{
+ int *piAddressVarOne = NULL;
+ wchar_t **pStVarOne = NULL;
+ int *lenStVarOne = NULL;
+ int m1 = 0, n1 = 0;
+
+ wchar_t **results = NULL;
+ int i = 0;
+
+ BOOL flagtrail = TRUE;
+ BOOL flagexpand = TRUE;
+
+ PathConvertType PType = AUTO_STYLE;
+
+ /* Check Input & Output parameters */
+ CheckRhs(1,4);
+ CheckLhs(1,1);
+
+
+ if (Rhs > 3)
+ {
+ int *piAddressVarFour = NULL;
+ wchar_t *pStVarFour = NULL;
+ int lenStVarFour = 0;
+ int m4 = 0, n4 = 0;
+
+ getVarAddressFromPosition(4, &piAddressVarFour);
+ if (getVarType(piAddressVarFour) != sci_strings)
+ {
+ Scierror(999,_("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 4);
+ return 0;
+ }
+
+ getVarDimension(piAddressVarFour, &m4, &n4);
+
+ if ( (m4 != n4) && (n4 != 1) )
+ {
+ Scierror(999,_("%s: Wrong size for input argument #%d: A string expected.\n"), fname, 4);
+ return 0;
+ }
+
+ getMatrixOfWideString(piAddressVarFour, &m4, &n4, &lenStVarFour, &pStVarFour);
+
+ pStVarFour = (wchar_t*)MALLOC(sizeof(wchar_t)*(lenStVarFour + 1));
+ if (pStVarFour == NULL)
+ {
+ Scierror(999,_("%s : Memory allocation error.\n"),fname);
+ return 0;
+ }
+
+ getMatrixOfWideString(piAddressVarFour, &m4, &n4, &lenStVarFour, &pStVarFour);
+
+ if ( (wcscmp(pStVarFour, L"w") == 0) || (wcscmp(pStVarFour, L"u") == 0) )
+ {
+ if (wcscmp(pStVarFour, L"w") == 0)
+ {
+ PType = WINDOWS_STYLE;
+ }
+ else
+ {
+ PType = UNIX_STYLE;
+ }
+ if (pStVarFour) {FREE(pStVarFour); pStVarFour = NULL;}
+ }
+ else
+ {
+ if (pStVarFour) {FREE(pStVarFour); pStVarFour = NULL;}
+ Scierror(999,_("%s: Wrong value for input argument #%d: ''w'' or ''u'' string expected.\n"), fname, 4);
+ return 0;
+ }
+ }
+
+ if (Rhs > 2)
+ {
+ int *piAddressVarThree = NULL;
+ int *piData = NULL;
+ int m3 = 0, n3 = 0;
+
+ getVarAddressFromPosition(3, &piAddressVarThree);
+ if (getVarType(piAddressVarThree) != sci_boolean)
+ {
+ Scierror(999,_("%s: Wrong type for input argument #%d: A boolean expected.\n"), fname, 3);
+ return 0;
+ }
+
+ getVarDimension(piAddressVarThree, &m3, &n3);
+
+ if ( (m3 != n3) && (n3 != 1) )
+ {
+ Scierror(999,_("%s: Wrong size for input argument #%d: A boolean expected.\n"), fname, 3);
+ return 0;
+ }
+
+ getMatrixOfBoolean(piAddressVarThree, &m3, &n3, &piData);
+ flagexpand = piData[0];
+ }
+
+ if (Rhs > 1)
+ {
+ int *piAddressVarTwo = NULL;
+ int *piData = NULL;
+ int m2 = 0, n2 = 0;
+
+ getVarAddressFromPosition(2, &piAddressVarTwo);
+ if (getVarType(piAddressVarTwo) != sci_boolean)
+ {
+ Scierror(999,_("%s: Wrong type for input argument #%d: A boolean expected.\n"), fname, 2);
+ return 0;
+ }
+
+ getVarDimension(piAddressVarTwo, &m2, &n2);
+
+ if ( (m2 != n2) && (n2 != 1) )
+ {
+ Scierror(999,_("%s: Wrong size for input argument #%d: A boolean expected.\n"), fname, 2);
+ return 0;
+ }
+
+ getMatrixOfBoolean(piAddressVarTwo, &m2, &n2, &piData);
+ flagtrail = piData[0];
+ }
+
+ getVarAddressFromPosition(1, &piAddressVarOne);
+
+ if (getVarType(piAddressVarOne) == sci_matrix)
+ {
+ getVarDimension(piAddressVarOne, &m1, &n1);
+ if ( (m1 == n1) && (m1 == 0) )
+ {
+ createMatrixOfDouble(Rhs + 1, m1, n1, NULL);
+ LhsVar(1) = Rhs + 1;
+ C2F(putlhsvar)();
+ }
+ else
+ {
+ Scierror(999,_("%s: Wrong type for input argument #%d: String array expected.\n"), fname, 1);
+ }
+ }
+ else if (getVarType(piAddressVarOne) == sci_strings)
+ {
+ getVarDimension(piAddressVarOne, &m1, &n1);
+
+ lenStVarOne = (int*)MALLOC(sizeof(int) * (m1 * n1));
+ if (lenStVarOne == NULL)
+ {
+ Scierror(999,_("%s : Memory allocation error.\n"),fname);
+ return 0;
+ }
+
+ pStVarOne = (wchar_t**)MALLOC(sizeof(wchar_t*) * (m1 * n1));
+ if (pStVarOne == NULL)
+ {
+ if (lenStVarOne) {FREE(lenStVarOne); lenStVarOne = NULL;}
+ Scierror(999,_("%s : Memory allocation error.\n"),fname);
+ return 0;
+ }
+
+ results = (wchar_t **)MALLOC(sizeof(wchar_t*) * (m1 * n1));
+
+ if (results == NULL)
+ {
+ if (lenStVarOne) {FREE(lenStVarOne); lenStVarOne = NULL;}
+ freeArrayOfWideString(pStVarOne, m1 * n1);
+ Scierror(999,_("%s : Memory allocation error.\n"),fname);
+ return 0;
+ }
+
+ getMatrixOfWideString(piAddressVarOne, &m1, &n1, lenStVarOne, pStVarOne);
+
+ for( i = 0; i < m1 * n1; i++)
+ {
+ results[i] = pathconvertW(pStVarOne[i], flagtrail, flagexpand, PType);
+ }
+
+ createMatrixOfWideString(Rhs + 1, m1, n1, results);
+ LhsVar(1) = Rhs + 1;
+ C2F(putlhsvar)();
+
+ if (lenStVarOne) {FREE(lenStVarOne); lenStVarOne = NULL;}
+ freeArrayOfWideString(results, m1 * n1);
+ }
+ else
+ {
+ Scierror(999,_("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 1);
+ return 0;
+ }
+ return 0;
+}
+/*--------------------------------------------------------------------------*/
<PRIMITIVE gatewayId="34" primitiveId="38" primitiveName="isfile" />
<PRIMITIVE gatewayId="34" primitiveId="39" primitiveName="fileparts" />
<PRIMITIVE gatewayId="34" primitiveId="40" primitiveName="movefile" />
+<PRIMITIVE gatewayId="34" primitiveId="41" primitiveName="basename" />
+<PRIMITIVE gatewayId="34" primitiveId="42" primitiveName="pathconvert" />
</GATEWAY>
--- /dev/null
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2009 - DIGITEO - Allan CORNET
+*
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution. The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+/*--------------------------------------------------------------------------*/
+#include "basename.h"
+#include "MALLOC.h"
+#include "expandPathVariable.h"
+#include "splitpath.h"
+#include "charEncoding.h"
+/*--------------------------------------------------------------------------*/
+wchar_t *basenameW(wchar_t *wcfullfilename, BOOL bExpand)
+{
+ wchar_t *basename_str = NULL;
+ if (wcfullfilename)
+ {
+ wchar_t *expandedPath = expandPathVariableW(wcfullfilename);
+ if (expandedPath)
+ {
+ wchar_t *wcdrv = MALLOC(sizeof(wchar_t*) * ((int)wcslen(expandedPath) + 1));
+ wchar_t* wcdir = MALLOC(sizeof(wchar_t*) * ((int)wcslen(expandedPath) + 1));
+ wchar_t* wcname = MALLOC(sizeof(wchar_t*) * ((int)wcslen(expandedPath) + 1));
+ wchar_t* wcext = MALLOC(sizeof(wchar_t*) * ((int)wcslen(expandedPath) + 1));
+
+ splitpathW(expandedPath, bExpand, wcdrv, wcdir, wcname, wcext);
+
+ if (wcname)
+ {
+ basename_str = wcname;
+ }
+
+ if (wcdrv) {FREE(wcdrv); wcdrv = NULL;}
+ if (wcdir) {FREE(wcdir); wcdir = NULL;}
+ if (wcext) {FREE(wcext); wcext = NULL;}
+
+ FREE(expandedPath);
+ expandedPath = NULL;
+ }
+ }
+ return basename_str;
+}
+/*--------------------------------------------------------------------------*/
+char *basename(char *fullfilename, BOOL bExpand)
+{
+ char *result = NULL;
+ if (fullfilename)
+ {
+ wchar_t *wcresult = NULL;
+ wchar_t *wcfullfilename = to_wide_string(fullfilename);
+
+ wcresult = basenameW(wcfullfilename, bExpand);
+ result = wide_string_to_UTF8(wcresult);
+ if (wcfullfilename) {FREE(wcfullfilename); wcfullfilename = NULL;}
+ if (wcresult) {FREE(wcresult); wcresult = NULL;}
+ }
+ return result;
+}
+/*--------------------------------------------------------------------------*/
--- /dev/null
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2009 - DIGITEO - Allan CORNET
+*
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution. The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+
+#ifndef __BASENAME_H__
+#define __BASENAME_H__
+
+#include <wchar.h>
+#include "BOOL.h"
+
+
+/**
+* strip directory and suffix from filenames
+* @param[in] filename
+* @param[in] BOOL flagexpand
+* @return basename
+*/
+char *basename(char *fullfilename, BOOL bExpand);
+
+
+/**
+* strip directory and suffix from filenames (wide string)
+* @param[in] filename
+* @param[in] BOOL flagexpand
+* @return basename
+*/
+wchar_t *basenameW(wchar_t *wcfullfilename, BOOL bExpand);
+
+#endif
\ No newline at end of file
#include "PATH_MAX.h"
#include "api_string.h"
#include "api_common.h"
+#include "getlongpathname.h"
/*--------------------------------------------------------------------------*/
struct VARIABLEALIAS
{
wchar_t *VariableName;
};
/*--------------------------------------------------------------------------*/
-#define NB_ALIAS 6
+#define NB_ALIAS 7
static struct VARIABLEALIAS VARIABLES_words[NB_ALIAS] =
{
{L"SCIHOME", L"SCIHOME"},
+ {L"WSCI", L"WSCI"},
{L"SCI", L"SCI"},
{L"~", L"home"},
{L"HOME", L"home"},
VARVALUE = (wchar_t*)MALLOC(sizeof(wchar_t)*(VARVALUElen + 1));
if (VARVALUE)
{
+ BOOL bConvLong = FALSE;
+ wchar_t *LongName = NULL;
readNamedMatrixOfWideString(varname, &m, &n, &VARVALUElen, &VARVALUE);
+ LongName = getlongpathnameW(VARVALUE, &bConvLong);
+ if (LongName)
+ {
+ FREE(VARVALUE);
+ VARVALUE = LongName;
+ }
}
}
}
char *getlongpathname(char *shortpathname,BOOL *convertok)
{
char *LongName = NULL;
-
- if (shortpathname)
+ wchar_t *wcshortpathname = to_wide_string(shortpathname);
+ if (wcshortpathname)
+ {
+ wchar_t *wcLongName = getlongpathnameW(wcshortpathname, convertok);
+ if (wcLongName)
+ {
+ LongName = wide_string_to_UTF8(wcLongName);
+ FREE(wcLongName); wcLongName = NULL;
+ }
+ else
+ {
+ LongName = strdup(shortpathname);
+ *convertok = FALSE;
+ }
+ }
+ else
{
- #ifdef _MSC_VER
- /* first we try to call to know path length */
- wchar_t *wLongName = NULL;
- wchar_t *wshortpathname = to_wide_string(shortpathname);
- int length = GetLongPathNameW(wshortpathname, NULL, 0);
- if (length <= 0 ) length = MAX_PATH_LONG;
+ LongName = strdup(shortpathname);
+ *convertok = FALSE;
+ }
+ return LongName;
+}
+/*--------------------------------------------------------------------------*/
+wchar_t *getlongpathnameW(wchar_t *wcshortpathname,BOOL *convertok)
+{
+ wchar_t *wcLongName = NULL;
+
+ #ifdef _MSC_VER
+ /* first we try to call to know path length */
+ int length = GetLongPathNameW(wcshortpathname, NULL, 0);
+ if (length <= 0 ) length = MAX_PATH_LONG;
- wLongName = (wchar_t*)MALLOC((length + 1) * sizeof(wchar_t));
+ wcLongName = (wchar_t*)MALLOC((length + 1) * sizeof(wchar_t));
- if (wLongName)
+ if (wcLongName)
+ {
+ /* second converts path */
+ if (GetLongPathNameW(wcshortpathname, wcLongName, length))
{
- /* second converts path */
- if (GetLongPathNameW(wshortpathname, wLongName, length))
- {
- LongName = wide_string_to_UTF8(wLongName);
- *convertok = TRUE;
- }
- else
- {
- /* FAILED */
- LongName = strdup(shortpathname);
- *convertok = FALSE;
- }
- if (wLongName) {FREE(wLongName);wLongName = NULL;}
+ *convertok = TRUE;
}
else
{
/* FAILED */
- LongName = strdup(shortpathname);
+ if (wcLongName) wcscpy(wcLongName, wcshortpathname);
*convertok = FALSE;
}
- if (wshortpathname) { FREE(wshortpathname); wshortpathname = NULL;}
- #else
- /* Linux */
- int length = (int)strlen(shortpathname) + 1;
- LongName = (char*)MALLOC(length * sizeof(char));
- if (LongName) strcpy(LongName, shortpathname);
- *convertok = FALSE;
- #endif
}
else
{
+ /* FAILED */
*convertok = FALSE;
}
- return LongName;
+ #else
+ /* Linux */
+ int len = (int)wcslen(wcshortpathname) + 1;
+ wcLongName = (wchar_t*)MALLOC(len * sizeof(wchar_t));
+ if (wcLongName) wcscpy(wcLongName, wcshortpathname);
+ *convertok = FALSE;
+ #endif
+ return wcLongName;
}
/*--------------------------------------------------------------------------*/
#ifndef __GETLONGPATHNAME_H__
#define __GETLONGPATHNAME_H__
+#include <wchar.h>
#include "BOOL.h" /* BOOL */
/**
*/
char *getlongpathname(char *shortpathname,BOOL *convertok);
+/**
+* Retrieves the long path form of the specified path (wide string)
+* @param[in] short path name
+* @param[out] TRUE if conversion is ok
+* @return long path name
+* on Linux returns same path name
+* used for Windows
+*/
+wchar_t *getlongpathnameW(wchar_t *wcshortpathname,BOOL *convertok);
+
#endif /* __GETLONGPATHNAME_H__ */
/*--------------------------------------------------------------------------*/
--- /dev/null
+/*--------------------------------------------------------------------------*/
+/*
+* ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) DIGITEO - 2009 - Allan CORNET
+*
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution. The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+/*--------------------------------------------------------------------------*/
+#include "pathconvert.h"
+#include "MALLOC.h"
+#include "expandPathVariable.h"
+#include "splitpath.h"
+#include "charEncoding.h"
+#include "BOOL.h"
+/*--------------------------------------------------------------------------*/
+#define CYGWINSTART L"/cygdrive/"
+/*--------------------------------------------------------------------------*/
+static wchar_t *cygwintowindowspath(wchar_t *cygwinpath, BOOL *bConverted);
+static wchar_t *windowstocygwinpath(wchar_t *windowspath, BOOL *bConverted);
+/*--------------------------------------------------------------------------*/
+wchar_t *pathconvertW(wchar_t* wcpath, BOOL flagtrail, BOOL flagexpand, PathConvertType PType)
+{
+ wchar_t *convertedPath = NULL;
+ if (wcpath)
+ {
+ BOOL bOK = FALSE;
+ BOOL bConvCyg = FALSE;
+ wchar_t *tmppath = NULL;
+ PathConvertType PTypelocal = PType;
+ int i = 0;
+
+ if (PType == AUTO_STYLE)
+ {
+ #ifdef _MSC_VER
+ PTypelocal = WINDOWS_STYLE;
+ #else
+ PTypelocal = UNIX_STYLE;
+ #endif
+ }
+
+ if (PTypelocal == WINDOWS_STYLE)
+ {
+ tmppath = cygwintowindowspath(wcpath, &bConvCyg);
+ }
+ else
+ {
+ tmppath = windowstocygwinpath(wcpath, &bConvCyg);
+ }
+
+ if (tmppath)
+ {
+ if (flagexpand)
+ {
+ convertedPath = expandPathVariableW(tmppath);
+ }
+ else
+ {
+ convertedPath = (wchar_t*)MALLOC(sizeof(wchar_t) * ((int)wcslen(tmppath) + 1));
+ wcscpy(convertedPath, tmppath);
+ }
+ if (tmppath) {FREE(tmppath); tmppath = NULL;}
+
+ if (flagtrail)
+ {
+ int currentLen = (int) wcslen(convertedPath);
+ if ( (convertedPath[currentLen - 1] != L'/') && (convertedPath[currentLen - 1] != L'\\') )
+ {
+ convertedPath = (wchar_t*)REALLOC(convertedPath, (currentLen + 2) * sizeof(wchar_t));
+ if (PTypelocal == WINDOWS_STYLE)
+ {
+ wcscat(convertedPath, L"\\");
+ }
+ else
+ {
+ wcscat(convertedPath, L"/");
+ }
+ }
+ }
+ else
+ {
+ int currentLen = (int) wcslen(convertedPath);
+ if ( (convertedPath[currentLen - 1] == L'/') || (convertedPath[currentLen - 1] == L'\\') )
+ {
+ convertedPath[currentLen - 1] = L'\0';
+ }
+ }
+
+ for(i = 0; i < (int)wcslen(convertedPath); i++)
+ {
+ if (PTypelocal == WINDOWS_STYLE)
+ {
+ if (convertedPath[i] == L'/') convertedPath[i] = L'\\';
+ }
+ else
+ {
+ if (convertedPath[i] == L'\\') convertedPath[i] = L'/';
+ }
+ }
+ }
+ }
+ return convertedPath;
+}
+/*--------------------------------------------------------------------------*/
+char *pathconvert(char* path, BOOL flagtrail, BOOL flagexpand, PathConvertType PType)
+{
+ char *convertedPath = NULL;
+ if (path)
+ {
+ wchar_t *wcpath = to_wide_string(path);
+ if (wcpath)
+ {
+ wchar_t *wcconvertedPath = pathconvertW(wcpath,flagtrail,flagexpand,PType);
+ if (wcconvertedPath)
+ {
+ convertedPath = wide_string_to_UTF8(wcconvertedPath);
+ FREE(wcconvertedPath);
+ wcconvertedPath = NULL;
+ }
+ }
+ }
+ return convertedPath;
+}
+/*--------------------------------------------------------------------------*/
+static wchar_t *cygwintowindowspath(wchar_t *cygwinpath, BOOL *bConverted)
+{
+ wchar_t *windowspath = NULL;
+ *bConverted = FALSE;
+ if (cygwinpath)
+ {
+ int lenBegin = (int)wcslen(CYGWINSTART);
+ int lenPath = (int)wcslen(cygwinpath);
+
+ windowspath = (wchar_t*)MALLOC(sizeof(wchar_t) * (lenPath + 1));
+
+ if ( wcsncmp(cygwinpath, CYGWINSTART, lenBegin) == 0)
+ {
+ if (lenBegin == lenPath)
+ {
+ if (windowspath)
+ {
+ wcscpy(windowspath, cygwinpath);
+ *bConverted = FALSE;
+ }
+ }
+ else
+ {
+ if ( (lenPath > lenBegin) && iswalpha(cygwinpath[lenBegin]) )
+ {
+ if ( (lenPath >= lenBegin + 1) &&
+ ((cygwinpath[lenBegin + 1]== L'/') || (cygwinpath[lenBegin + 1]== L'\\')) )
+ {
+ windowspath[0] = cygwinpath[lenBegin];
+ windowspath[1] = L':';
+ windowspath[2] = L'\0';
+
+ if (lenPath > lenBegin + 1)
+ {
+ wcscat(windowspath,&cygwinpath[lenBegin + 1]);
+ }
+ *bConverted = TRUE;
+ }
+ else
+ {
+ if (windowspath)
+ {
+ wcscpy(windowspath, cygwinpath);
+ }
+ *bConverted = FALSE;
+ }
+ }
+ else
+ {
+ if (windowspath)
+ {
+ wcscpy(windowspath, cygwinpath);
+ }
+ *bConverted = FALSE;
+ }
+ }
+ }
+ else
+ {
+ if (windowspath)
+ {
+ wcscpy(windowspath, cygwinpath);
+ }
+ *bConverted = FALSE;
+ }
+ }
+ return windowspath;
+}
+/*--------------------------------------------------------------------------*/
+static wchar_t *windowstocygwinpath(wchar_t *windowspath, BOOL *bConverted)
+{
+ wchar_t *cygwinpath = NULL;
+ *bConverted = FALSE;
+
+ if (windowspath)
+ {
+ wchar_t *wcdrv = MALLOC(sizeof(wchar_t*) * ((int)wcslen(windowspath) + 1));
+ wchar_t* wcdir = MALLOC(sizeof(wchar_t*) * ((int)wcslen(windowspath) + 1));
+ wchar_t* wcname = MALLOC(sizeof(wchar_t*) * ((int)wcslen(windowspath) + 1));
+ wchar_t* wcext = MALLOC(sizeof(wchar_t*) * ((int)wcslen(windowspath) + 1));
+
+ splitpathW(windowspath, FALSE, wcdrv, wcdir, wcname, wcext);
+ if (wcscmp(wcdrv, L"") != 0)
+ {
+ int len = (int)wcslen(CYGWINSTART) + (int)wcslen(wcdrv) +
+ (int)wcslen(wcdir) + (int)wcslen(wcname) +
+ (int)wcslen(wcext) + 3;
+
+ cygwinpath = (wchar_t*)MALLOC(sizeof(wchar_t) * len);
+ if (cygwinpath)
+ {
+ wcscpy(cygwinpath, CYGWINSTART);
+ wcscat(cygwinpath, wcdrv);
+ len = (int)wcslen(cygwinpath);
+ if (cygwinpath[len - 1] == L':')
+ {
+ cygwinpath[len - 1] = L'\0';
+ }
+ if (wcscmp(wcdir, L"") != 0)
+ {
+ wcscat(cygwinpath, wcdir);
+
+ if (wcscmp(wcname, L"") != 0)
+ {
+ wcscat(cygwinpath, wcname);
+ if (wcscmp(wcext, L"") != 0)
+ {
+ wcscat(cygwinpath, wcext);
+ }
+ }
+ }
+ }
+ *bConverted = TRUE;
+ }
+ else
+ {
+ cygwinpath = (wchar_t*)MALLOC(sizeof(wchar_t) * ((int)wcslen(windowspath) + 1));
+ if (cygwinpath)
+ {
+ wcscpy(cygwinpath, windowspath);
+ }
+ }
+
+ if (wcdrv){FREE(wcdrv);wcdrv = NULL;}
+ if (wcdir){FREE(wcdir);wcdir = NULL;}
+ if (wcname){FREE(wcname);wcname = NULL;}
+ if (wcext){FREE(wcext);wcext = NULL;}
+ }
+ return cygwinpath;
+}
+/*--------------------------------------------------------------------------*/
--- /dev/null
+/*--------------------------------------------------------------------------*/
+/*
+* ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) DIGITEO - 2009 - Allan CORNET
+*
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution. The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+/*--------------------------------------------------------------------------*/
+#ifndef __PATHCONVERT_H__
+#define __PATHCONVERT_H__
+
+#include <wchar.h>
+#include "BOOL.h"
+
+typedef enum {
+WINDOWS_STYLE = 0,
+UNIX_STYLE = 1,
+AUTO_STYLE = 2
+} PathConvertType;
+
+wchar_t *pathconvertW(wchar_t* wcpath, BOOL flagtrail, BOOL flagexpand, PathConvertType PType);
+
+char *pathconvert(char* path, BOOL flagtrail, BOOL flagexpand, PathConvertType PType);
+
+#endif /* PATHCONVERT_H__ */
+/*--------------------------------------------------------------------------*/
#include "charEncoding.h"
#include "PATH_MAX.h"
#include "MALLOC.h"
+#include "expandPathVariable.h"
/*--------------------------------------------------------------------------*/
-void splitpathW(const wchar_t* path, wchar_t* drv, wchar_t* dir, wchar_t* name, wchar_t* ext)
+void splitpathW(const wchar_t* path, BOOL bExpand, wchar_t* drv, wchar_t* dir, wchar_t* name, wchar_t* ext)
{
wchar_t* duplicate_path = NULL;
wchar_t* begin_duplicate_path = NULL;
{
int i = 0;
- duplicate_path = (wchar_t*)MALLOC(sizeof(wchar_t)* ((int)wcslen(path) + 1));
+ if (bExpand)
+ {
+ duplicate_path = expandPathVariableW((wchar_t*)path);
+ }
+ else
+ {
+ duplicate_path = (wchar_t*)MALLOC(sizeof(wchar_t) * ((int)wcslen(path) + 1));
+ if (duplicate_path) wcscpy(duplicate_path, path);
+ }
+
if (duplicate_path == NULL) return;
- wcscpy(duplicate_path, path);
begin_duplicate_path = duplicate_path;
for(i = 0; i < (int)wcslen(duplicate_path); i++)
return;
}
-
-#ifdef _MSC_VER
if (duplicate_path)
{
- if (wcslen(duplicate_path) > 3)
+ if (wcslen(duplicate_path) > 2)
{
- if (duplicate_path[0] && duplicate_path[1]==L':' && duplicate_path[2]==L'\\')
+ if (duplicate_path[0] && duplicate_path[1]==L':' && ( (duplicate_path[2]==L'\\') || (duplicate_path[2]==L'/') ) )
{
if (drv)
{
}
}
}
-#endif
+
/* find the last slash in the path */
#ifdef _MSC_VER
}
}
/*--------------------------------------------------------------------------*/
-void splitpath(const char* path, char* drv, char* dir, char* name, char* ext)
+void splitpath(const char* path, BOOL bExpand, char* drv, char* dir, char* name, char* ext)
{
wchar_t *wcpath = to_wide_string((char*)path);
wchar_t *wcdrv = to_wide_string((char*)path);
char *buffer = NULL;
- splitpathW(wcpath, wcdrv, wcdir, wcname, wcext);
+ splitpathW(wcpath, bExpand, wcdrv, wcdir, wcname, wcext);
buffer = wide_string_to_UTF8(wcdrv);
if (buffer)
r = pathconvert('SCI/modules/fileio\macros/foo.sci',%f,%f,'w');
if r <> ref then bugmes();quit;end
if MSDOS then
- ref = WSCI + '\modules\fileio\macros\foo.sci';
+ ref = WSCI + '\modules\fileio\macros\cd.sci';
else
- ref = SCI + '\modules\fileio\macros\foo.sci';
+ ref = SCI + '\modules\fileio\macros\cd.sci';
ref = strsubst(ref,filesep(),'\');
end
-r = pathconvert('SCI/modules/fileio/macros/foo.sci',%f,%t,'w');
+r = pathconvert('SCI/modules/fileio/macros/cd.sci',%f,%t,'w');
if r <> ref then bugmes();quit;end
ref = home + '\modules\fileio\macros\foo.sci';
if ~MSDOS then
if r <> ref then pause, end
if MSDOS then
- ref = WSCI + '\modules\fileio\macros\foo.sci';
+ ref = WSCI + '\modules\fileio\macros\cd.sci';
else
- ref = SCI + '\modules\fileio\macros\foo.sci';
+ ref = SCI + '\modules\fileio\macros\cd.sci';
ref = strsubst(ref,filesep(),'\');
end
-r = pathconvert('SCI/modules/fileio/macros/foo.sci',%f,%t,'w');
+r = pathconvert('SCI/modules/fileio/macros/cd.sci',%f,%t,'w');
if r <> ref then pause, end
ref = home + '\modules\fileio\macros\foo.sci';
// Warning : order !!
// list of : filename , module
-listmacrostoload = ['pathconvert','fileio';
- 'listfiles','fileio'
+listmacrostoload = ['listfiles','fileio'
'%c_a_c','overloading';
- 'basename','fileio';
'mputl','fileio';
'genlib','functions';
];