Localization (fileio)
[scilab.git] / scilab / modules / fileio / sci_gateway / c / sci_createdir.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 "MALLOC.h"
18 #include "createdirectory.h"
19 #include "isdir.h"
20 #include "cluni0.h"
21 #include "warningmode.h"
22 #include "sciprint.h"
23 #include "Scierror.h"
24 #include "localization.h"
25 /*--------------------------------------------------------------------------*/
26 int C2F(sci_createdir)(char *fname,unsigned long l)
27 {
28         CheckRhs(1,1);
29         CheckLhs(0,1);
30
31         if (GetType(1) == sci_strings)
32         {
33                 BOOL bOK = FALSE;
34                 int m1 = 0, n1 = 0, l1 = 0;
35                 char expandedpath[PATH_MAX+1];
36                 int out_n = 0;
37                 char *VarName = NULL;
38
39                 GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);
40                 VarName=cstk(l1);
41
42                 C2F(cluni0)(VarName,expandedpath, &out_n,(int)strlen(VarName),PATH_MAX);
43
44                 if (!isdir(expandedpath))
45                 {
46                         bOK = createdirectory(expandedpath);
47                 }
48                 else
49                 {
50                         if (getWarningMode()) sciprint(_("%s: Warning: Directory '%s' already exists.\n"),fname,expandedpath);
51                         bOK = TRUE;
52                 }
53
54                 m1 = 1; n1 = 1;
55                 CreateVar(Rhs+1,MATRIX_OF_BOOLEAN_DATATYPE, &m1, &n1 ,&l1);
56                 *istk(l1) = bOK;
57
58                 LhsVar(1)=Rhs+1;
59                 C2F(putlhsvar)();
60         }
61         else
62         {
63                 Scierror(999,_("%s: Wrong type for input argument: String expected.\n"), fname);
64         }
65         return 0;
66 }
67 /*--------------------------------------------------------------------------*/