aae3337f44057bb68fb1309ec9b41ed0d141e55f
[scilab.git] / scilab / modules / fileio / sci_gateway / c / sci_removedir.c
1 /*
2  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  * Copyright (C) 2007 - INRIA - Allan CORNET
4  * Copyright (C) 2008 - INRIA - Bruno JOFRET
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 "removedir.h"
19 #include "isdir.h"
20 #include "Scierror.h"
21 #include "cluni0.h"
22 #include "localization.h"
23 /*--------------------------------------------------------------------------*/
24 int C2F(sci_removedir)(char *fname,unsigned long l)
25 {
26         CheckRhs(1,1);
27         CheckLhs(0,1);
28
29         if (GetType(1) == sci_strings)
30         {
31                 BOOL bOK = FALSE;
32                 int m1 = 0, n1 = 0, l1 = 0;
33                 char expandedpath[PATH_MAX+1];
34                 int out_n = 0;
35                 char *VarName = NULL;
36
37                 GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);
38                 VarName=cstk(l1);
39
40                 C2F(cluni0)(VarName,expandedpath, &out_n,(int)strlen(VarName),PATH_MAX);
41
42                 if ( isdir(expandedpath) )
43                 {
44                         bOK = removedir(expandedpath);
45                 }
46
47                 m1 = 1; n1 = 1;
48                 CreateVar(Rhs+1,MATRIX_OF_BOOLEAN_DATATYPE, &m1, &n1 ,&l1);
49                 *istk(l1) = bOK;
50
51                 LhsVar(1)=Rhs+1;
52                 C2F(putlhsvar)();
53         }
54         else
55         {
56                 Scierror(999,_("%s: Wrong type for first input argument: String expected.\n"), fname);
57         }
58         return 0;
59 }
60 /*--------------------------------------------------------------------------*/