HydroCODE_2D 0.1
This is a implementation of fully explict forward Euler scheme for 2-D Euler equations of motion on Eulerian coordinate
sys_pro.c
浏览该文件的文档.
1
6#include <stdio.h>
7#include <string.h>
8#include <math.h>
9
10/*
11 * To realize cross-platform programming.
12 * MKDIR: Create a subdirectory.
13 * ACCESS: Determine access permissions for files or folders.
14 * - mode=0: Test for existence.
15 * - mode=2: Test for write permission.
16 * - mode=4: Test for read permission.
17 */
18#ifdef _WIN32
19#include <io.h>
20#include <direct.h>
21#define ACCESS(path,mode) _access((path),(mode))
22#define MKDIR(path) _mkdir((path))
23#elif __linux__
24#include <unistd.h>
25#include <sys/stat.h>
26#define ACCESS(path,mode) access((path),(mode))
27#define MKDIR(path) mkdir((path), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)
28#endif
29
30
36void DispPro(const double pro, const int step)
37{
38 int j;
39 for (j = 0; j < 77; j++)
40 putchar('\b'); // Clears the current line to display the latest progress bar status.
41 for (j = 0; j < lround(pro/2); j++)
42 putchar('+'); // Print the part of the progress bar that has been completed, denoted by '+'.
43 for (j = 1; j <= 50-lround(pro/2); j++)
44 putchar('-'); // Print how much is left on the progress bar.
45 fprintf(stdout, " %6.2f%% STEP=%-8d", pro, step);
46 fflush(stdout);
47}
48
57int CreateDir(const char * pPath)
58{
59 if(0 == ACCESS(pPath,2))
60 return -1;
61
62 const char* pCur = pPath;
63 char tmpPath[FILENAME_MAX+40];
64 memset(tmpPath,0,sizeof(tmpPath));
65
66 int pos = 0;
67 while(*pCur++!='\0')
68 {
69 tmpPath[pos++] = *(pCur-1);
70
71 if(*pCur=='/' || *pCur=='\0')
72 {
73 if(0!=ACCESS(tmpPath,0) && strlen(tmpPath)>0)
74 {
75 MKDIR(tmpPath);
76 }
77 }
78 }
79 if(0 == ACCESS(pPath,2))
80 return 0;
81 else
82 return 1;
83}
int CreateDir(const char *pPath)
This is a function that recursively creates folders.
Definition: sys_pro.c:57
void DispPro(const double pro, const int step)
This function print a progress bar on one line of standard output.
Definition: sys_pro.c:36