summaryrefslogtreecommitdiff
path: root/src/util/File.c
blob: 541693c35b4d4ff58f5ee9a9f7b5119226c42050 (plain)
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
#include "cctk.h"

 /*@@
   @file      File.c
   @date      September 6th 1999
   @author    File handling routines
   @desc
   Miscellaneuous routines.
   @enddesc
 @@*/             

#include <malloc.h>
#include <stdio.h>

#include "cctk_WarnLevel.h"
#include "cctk_FortranString.h"

int CCTK_mkdir(char *dir)
{
  int retval;
  char *command;
  char *message;
 
  command = (char *)malloc(1024*sizeof(char));

  /***
    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); 
}