1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#include "cctk.h"
/*@@
@file File.c
@date September 6th 1999
@author Gabrielle Allen
@desc
File Handling routines
@enddesc
@@*/
#include <malloc.h>
#include <stdio.h>
#include "cctk_WarnLevel.h"
#include "cctk_FortranString.h"
#include "StoreHandledData.h"
static cHandledData *DirNames = NULL;
/*@@
@routine CCTK_mkdir
@date September 6th 1999
@author Gabrielle Allen
@desc
Create a directory, if we haven't already tried
to create it.
@enddesc
@@*/
int CCTK_mkdir(char *dir)
{
int retval;
int handle;
char *command;
char *message;
command = (char *)malloc(1024*sizeof(char));
/* Store directory name */
handle = Util_GetHandle(DirNames, dir, NULL);
if (handle < 0)
{
/* New directory name */
handle = Util_NewHandle(&DirNames, dir, NULL);
/***
TR 13/09/99: disabled use of MKDIRFLAGS until it also works for NT
This means either
- we make sure to always use the bash's mkdir command (which accepts
option '-p')
- call the dos shell with MKDIRFLAGS set to an empty string
- use the POSIX mkdir routine
The disadvantage for calling mkdir without '-p' under UNIX is now
that we can always create one subdirectory only which needs to be
relative to an existing directory.
***/
#if 0
sprintf(command, MKDIR MKDIRFLAGS " %s",dir);
#else
sprintf(command, MKDIR " %s",dir);
#endif
message = (char *)malloc(1024*sizeof(char));
sprintf(message,"Creating directory: \"%s\"",command);
CCTK_Info("Cactus",message);
free(message);
retval = system(command);
free(command);
}
return retval;
}
void FMODIFIER FORTRAN_NAME(CCTK_mkdir)(int *ierr, ONE_FORTSTRING_ARG)
{
int retval;
ONE_FORTSTRING_CREATE(arg1)
*ierr = CCTK_mkdir(arg1);
free(arg1);
}
|