IBR-DTNSuite
0.12
Main Page
Namespaces
Classes
Files
File List
File Members
IBR-DTNSuite
Namespaces
Classes
Files
File List
daemon
ibrcommon
ibrcommon
data
Base64.cpp
Base64.h
Base64Reader.cpp
Base64Reader.h
Base64Stream.cpp
Base64Stream.h
BLOB.cpp
BLOB.h
BloomFilter.cpp
BloomFilter.h
ConfigFile.cpp
ConfigFile.h
File.cpp
File.h
iobuffer.cpp
iobuffer.h
link
net
ssl
thread
xml
appstreambuf.cpp
appstreambuf.h
config.h
Exceptions.h
ibrcommon.h
Iterator.h
Logger.cpp
Logger.h
MonotonicClock.cpp
MonotonicClock.h
refcnt_ptr.h
SyslogStream.cpp
SyslogStream.h
TimeMeasurement.cpp
TimeMeasurement.h
TLSExceptions.h
ibrdtn
tools
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(std::list<File> &files)
const
;
79
84
bool
isRoot()
const
;
85
90
bool
isSystem()
const
;
91
96
bool
isDirectory()
const
;
97
102
std::string getPath()
const
;
103
108
std::string getBasename()
const
;
109
115
virtual
int
remove
(
bool
recursive =
false
);
116
122
File
get
(
const
std::string &filename)
const
;
123
128
File
getParent()
const
;
129
134
virtual
bool
exists()
const
;
135
139
virtual
void
update();
140
145
virtual
size_t
size()
const
;
146
150
virtual
time_t lastaccess()
const
;
151
155
virtual
time_t lastmodify()
const
;
156
160
virtual
time_t laststatchange()
const
;
161
166
static
void
createDirectory(
File
&path);
167
168
bool
operator==(
const
ibrcommon::File
&other)
const
;
169
bool
operator<(
const
ibrcommon::File
&other)
const
;
170
171
protected
:
172
File
(
const
std::string &path,
const
unsigned
char
t);
173
unsigned
char
_type
;
174
175
private
:
176
void
resolveAbsolutePath();
177
void
removeSlash();
178
std::string _path;
179
};
180
184
class
FileNotExistsException
:
public
ibrcommon::IOException
185
{
186
public
:
187
FileNotExistsException
(
ibrcommon::File
f)
throw
() :
IOException
(
"The file "
+ f.getPath() +
" does not exists."
)
188
{
189
};
190
};
191
195
class
TemporaryFile
:
public
File
196
{
197
public
:
198
TemporaryFile
(
const
File
&path,
const
std::string prefix =
"file"
);
199
virtual
~
TemporaryFile
();
200
201
private
:
202
static
std::string tmpname(
const
File
&path,
const
std::string prefix);
203
};
204
}
205
206
#endif
/* FILE_H_ */
ibrcommon
ibrcommon
data
File.h
Generated on Thu Mar 27 2014 09:26:20 for IBR-DTNSuite by
1.8.4