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