IBR-DTNSuite
0.10
Main Page
Namespaces
Classes
Files
File List
File Members
File.h
Go to the documentation of this file.
1
/*
2
* File.h
3
*
4
* Copyright (C) 2011 IBR, TU Braunschweig
5
*
6
* Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7
*
8
* Licensed under the Apache License, Version 2.0 (the "License");
9
* you may not use this file except in compliance with the License.
10
* You may obtain a copy of the License at
11
*
12
* http://www.apache.org/licenses/LICENSE-2.0
13
*
14
* Unless required by applicable law or agreed to in writing, software
15
* distributed under the License is distributed on an "AS IS" BASIS,
16
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
* See the License for the specific language governing permissions and
18
* limitations under the License.
19
*
20
*/
21
22
#ifndef IBRCOMMON_FILE_H_
23
#define IBRCOMMON_FILE_H_
24
25
//#define USE_FILE_LOCKING 1
26
27
#include <iostream>
28
#include <map>
29
#include <vector>
30
#include <list>
31
#include <dirent.h>
32
#include <stdio.h>
33
#include <sys/types.h>
34
#include <sys/stat.h>
35
#include "
ibrcommon/Exceptions.h
"
36
37
using namespace
std;
38
39
namespace
ibrcommon
40
{
45
class
File
46
{
47
public
:
51
File
();
52
58
File
(
const
std::string &path);
59
63
virtual
~
File
();
64
70
unsigned
char
getType()
const
;
71
78
int
getFiles(list<File> &files)
const
;
79
84
bool
isSystem()
const
;
85
90
bool
isDirectory()
const
;
91
96
std::string getPath()
const
;
97
102
std::string getBasename()
const
;
103
109
int
remove
(
bool
recursive =
false
);
110
116
File
get
(
string
filename)
const
;
117
122
File
getParent()
const
;
123
128
bool
exists()
const
;
129
133
void
update();
134
139
size_t
size()
const
;
140
144
time_t lastaccess()
const
;
145
149
time_t lastmodify()
const
;
150
154
time_t laststatchange()
const
;
155
160
static
void
createDirectory(
File
&path);
161
162
bool
operator==(
const
ibrcommon::File
&other)
const
;
163
bool
operator<(
const
ibrcommon::File
&other)
const
;
164
165
private
:
166
File
(
const
std::string &path,
const
unsigned
char
t);
167
void
resolveAbsolutePath();
168
void
removeSlash();
169
std::string _path;
170
unsigned
char
_type;
171
};
172
176
class
FileNotExistsException
:
public
ibrcommon::IOException
177
{
178
public
:
179
FileNotExistsException
(
ibrcommon::File
f)
throw
() :
IOException
(
"The file "
+ f.getPath() +
" does not exists."
)
180
{
181
};
182
};
183
187
class
TemporaryFile
:
public
File
188
{
189
public
:
190
TemporaryFile
(
const
File
&path,
const
std::string prefix =
"file"
);
191
virtual
~
TemporaryFile
();
192
193
private
:
194
static
std::string tmpname(
const
File
&path,
const
std::string prefix);
195
};
196
}
197
198
#endif
/* FILE_H_ */
ibrcommon
ibrcommon
data
File.h
Generated on Mon Jul 22 2013 15:16:00 for IBR-DTNSuite by
1.8.3.1