Localization (fileio)
[scilab.git] / scilab / modules / fileio / sci_gateway / c / sci_getlongpathname.c
1 /*
2  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  * Copyright (C) 2007 - INRIA - Allan CORNET
4  * ...
5  * 
6  * This file must be used under the terms of the CeCILL.
7  * This source file is licensed as described in the file COPYING, which
8  * you should have received as part of this distribution.  The terms
9  * are also available at    
10  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
11  *
12  */
13 /*--------------------------------------------------------------------------*/
14 #include <string.h>
15 #include "gw_fileio.h"
16 #include "stack-c.h"
17 #include "getlongpathname.h"
18 #include "localization.h"
19 #include "MALLOC.h"
20 #include "Scierror.h"
21 /*--------------------------------------------------------------------------*/
22 int C2F(sci_getlongpathname)(char *fname,unsigned long l)
23 {
24         static int l1,n1,m1;
25
26         CheckRhs(1,1);
27         CheckLhs(1,2);
28
29         if (GetType(1) == sci_strings)
30         {
31                 int bOK=FALSE;
32                 char *LongName=NULL;
33                 char *ShortName=NULL;
34
35                 GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);
36                 ShortName=cstk(l1);
37
38                 LongName = getlongpathname(ShortName,&bOK);
39
40                 n1=1;
41                 CreateVarFromPtr(Rhs+ 1,STRING_DATATYPE,(m1=(int)strlen(LongName), &m1),&n1,&LongName);
42                 LhsVar(1)=Rhs+1;
43
44                 if (LongName) {FREE(LongName);LongName=NULL;}
45
46                 if (Lhs != 1) /* Lhs == 2 */
47                 {
48                         int *bOkOutINT=(int*)MALLOC(sizeof(int));
49
50                         *bOkOutINT=bOK;
51                         n1=1;
52                         CreateVarFromPtr(Rhs+2,MATRIX_OF_BOOLEAN_DATATYPE, &n1, &n1, &bOkOutINT);
53                         LhsVar(2)=Rhs+2;
54                         if (bOkOutINT) {FREE(bOkOutINT);bOkOutINT=NULL;}
55                 }
56                 C2F(putlhsvar)();
57         }
58         else
59         {
60                 Scierror(999,_("%s: Wrong type for input argument: String expected.\n"),fname);
61         }
62         return 0;
63 }
64 /*--------------------------------------------------------------------------*/