FileIO.h
2.51 KB
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
91
92
93
94
95
#ifndef __FILE_IO_H__
#define __FILE_IO_H__
#include "AnubisSupport.h"
#include "CMString.h"
#ifdef WIN32
#include <windows.h>
#include <stdio.h>
#endif
#if defined(__BEOS__) || defined (_LINUX_)
#define ENV_PATH_SEPARATOR ':'
#elif defined(WIN32)
#define ENV_PATH_SEPARATOR ';'
#endif
#if defined(__BEOS__) || defined (_LINUX_)
#define FILE_SEPARATOR '/'
#elif defined(WIN32)
#define FILE_SEPARATOR '\\'
#endif
USING_NAMESPACE(CM);
/**
* Give the file separator character for the host operating system
* @return slash character under Linux, BeOS/Zeta and anti-slash character for Windows
*/
char FileSeparator(void);
/**
* Normalization of filename path, consist to transform any given wrong fileseparator to
* right format for the host operating system. For example under linux if you give
* the next filepath /usr/local\myfile the result of normalization will be
* /usr/local/myfile
* @pathName filepath to normalize
*/
#ifdef __cplusplus
extern "C" {
#endif
void NormalizeFileName(char *pathName);
#ifdef __cplusplus
}
#endif
String GetFileName(String pathName);
/**
*
*/
CM::String GetProgramRootDir(const char * argv0);
/** provide the current user dir of host OS
*
*/
CM::String GetUserDir(void);
/**
* Check the existence of the file
* @param fileToCheck
* @return true if the file exist otherwise false
*/
bool FileExist(CM::String fileToCheck);
/*
* Make a recursive copy from source directory to destination
* @param srcDir from where we copy
* @param destDir
*/
bool RecursiveCopy(const String &srcDir, const String &destDir);
/*
* create all given directories
* @param directory path to create
* @param mean the above directory have filename at the end
*/
int CreateAllDirectories(const char* directory, bool haveFile );
#ifdef WIN32
int CM_CopyDir(const String& sourceDirPath, const String& destDirPath, const String &filter, bool recursive);
int CM_CopyFileDir(const String &sourceDirPath, const String &destDirPath, const String &filter);
int CM_CopyFile(const String& srcFile, const String& desFile);
//File utils functions
void CM_TimetToFileTime( time_t t, LPFILETIME pft );
void CM_FileTimeToTime( time_t& t, LPFILETIME pft );
bool CM_SetModificationTime(const char* file_name, const time_t aModificationTime);
bool CM_SetAccessTime(const char* file_name, const time_t aAccessTime);
void CM_SetAllTime(FILE* srcFile, FILE* dstFile);
#endif
char *GetWorkingDirectory(char *buf, int sz);
String GetCwd();
#endif