BALL
1.5.0
include
BALL
SYSTEM
directory.h
Go to the documentation of this file.
1
// -*- Mode: C++; tab-width: 2; -*-
2
// vi: set ts=2:
3
//
4
// $Id: directory.h,v 1.29.16.1 2007/03/25 21:25:38 oliver Exp $
5
//
6
7
#ifndef BALL_SYSTEM_DIRECTORY_H
8
#define BALL_SYSTEM_DIRECTORY_H
9
10
#ifndef BALL_COMMON_H
11
# include <
BALL/common.h
>
12
#endif
13
14
#ifndef BALL_CONCEPT_PROCESSOR_H
15
# include <
BALL/CONCEPT/processor.h
>
16
#endif
17
18
#ifndef BALL_DATATYPE_STRING_H
19
# include <
BALL/DATATYPE/string.h
>
20
#endif
21
22
#ifndef BALL_SYSTEM_FILESYSTEM_H
23
# include <
BALL/SYSTEM/fileSystem.h
>
24
#endif
25
26
#ifdef BALL_HAS_DIRENT_H
27
# include <dirent.h>
28
#endif
29
#ifdef BALL_HAS_UNISTD_H
30
# include <unistd.h>
31
#endif
32
#ifdef BALL_HAS_SYS_STAT_H
33
# include <sys/stat.h>
34
#endif
35
#ifdef BALL_HAS_DIRECT_H
36
# include <direct.h>
37
#endif
38
#include <cstdio>
39
#ifdef BALL_COMPILER_MSVC
40
#define WINDOWS_LEAN_AND_MEAN
41
#include <windows.h>
42
#define mode_t int
43
#endif
44
45
namespace
BALL
46
{
50
class
BALL_EXPORT
Directory
51
{
52
#ifndef BALL_OS_WINDOWS
53
# define INVALID_HANDLE_VALUE 0
54
#endif
55
56
public
:
57
61
66
static
const
Size
MAX_PATH_LENGTH
;
67
69
72
79
Directory
();
80
89
Directory
(
const
String
& directory_path,
bool
set_current =
false
);
90
96
Directory
(
const
Directory
& directory);
97
100
~
Directory
();
101
106
void
clear();
107
110
void
destroy();
111
113
116
124
bool
set(
const
String
& directory_path,
bool
set_current =
false
);
125
130
void
set(
const
Directory
& directory);
131
135
Directory
& operator = (
const
Directory
& directory);
136
141
void
get(
Directory
& directory)
const
;
143
147
153
const
String
& getPath()
const
;
154
162
bool
rename(
String
old_path,
String
new_path);
163
168
bool
renameTo(
String
new_path);
169
174
bool
setCurrent(
String
directory_path);
175
179
bool
setCurrent();
180
188
bool
create(
String
path,
const
mode_t& mode = 0777);
189
196
bool
remove(
String
old_path);
197
202
bool
remove();
203
208
bool
getFirstEntry(
String
& entry);
209
214
bool
getNextEntry(
String
& entry);
215
219
Size
countItems();
220
224
Size
countFiles();
225
229
Size
countDirectories();
230
237
bool
find(
const
String
& filename,
String
& filepath);
238
240
243
248
bool
has(
const
String
& item);
249
255
bool
isValid()
const
;
256
260
bool
isCurrent()
const
;
261
265
bool
isEmpty();
266
270
bool
operator ==
(
const
Directory
& directory)
const
;
271
275
bool
operator !=
(
const
Directory
& directory)
const
;
276
278
static
String
getUserHomeDir();
279
281
static
bool
changeToUserHomeDir();
282
284
285
private
:
286
287
//_wrapper function around getcwd to handle different naming conventions in different OS
288
String
getcwd_();
289
290
//_wrapper function around chdir to handle different naming conventions in different OS
291
int
chdir_(
const
String
& new_dir);
292
293
//_switch to this dir
294
void
synchronize_();
295
296
//_switch back to the working directory
297
bool
desynchronize_(
bool
result =
true
);
298
#ifdef BALL_COMPILER_MSVC
299
HANDLE dirent_;
300
HANDLE dir_;
301
#else
302
DIR* dir_;
303
dirent* dirent_;
304
#endif
305
String
directory_path_;
306
String
backup_path_;
307
};
308
309
# ifndef BALL_NO_INLINE_FUNCTIONS
310
# include <BALL/SYSTEM/directory.iC>
311
# endif
312
313
}
// namespace BALL
314
315
#endif // BALL_SYSTEM_DIRECTORY_H
BALL_EXPORT
#define BALL_EXPORT
Definition:
COMMON/global.h:50
BALL::operator!=
BALL_EXPORT bool operator!=(const String &s1, const String &s2)
BALL_SIZE_TYPE
BALL
Definition:
constants.h:12
BALL::String
Definition:
string.h:56
BALL::Directory::MAX_PATH_LENGTH
static const Size MAX_PATH_LENGTH
Definition:
directory.h:66
string.h
processor.h
BALL::Directory
Definition:
directory.h:50
BALL::operator==
BALL_EXPORT bool operator==(const String &s1, const String &s2)
common.h
fileSystem.h
Generated by
1.8.16