libdigidocpp
Main Page
Namespaces
Classes
Files
File List
File Members
File.h
Go to the documentation of this file.
1
/*
2
* libdigidocpp
3
*
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2.1 of the License, or (at your option) any later version.
8
*
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
13
*
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
*
18
*/
19
20
#pragma once
21
22
#include "../Exception.h"
23
24
#include <stack>
25
26
#ifdef _WIN32
27
#define f_string std::wstring
28
#else
29
#define f_string std::string
30
#endif
31
32
namespace
digidoc
33
{
34
namespace
util
35
{
36
42
class
File
43
{
44
public
:
45
static
std::string
env
(
const
std::string &varname);
46
static
std::string
cwd
();
47
static
bool
fileExists
(
const
std::string&
path
);
48
static
bool
directoryExists
(
const
std::string& path);
49
static
f_string
encodeName
(
const
std::string &
fileName
);
50
static
std::string
decodeName
(
const
f_string
&localFileName);
51
static
bool
isRelative
(
const
std::string &path);
52
static
tm*
modifiedTime
(
const
std::string &path);
53
static
std::string
fileName
(
const
std::string& path);
54
static
std::string
directory
(
const
std::string& path);
55
static
std::string
path
(
const
std::string& directory,
const
std::string& relativePath,
bool
unixStyle =
false
);
56
static
std::string
fullPathUrl
(
const
std::string& fullDirectory,
const
std::string& relativeFilePath);
57
static
std::string
tempFileName
();
58
static
std::string
tempDirectory
();
59
static
void
createDirectory
(
const
std::string& path)
throw
(
IOException
);
60
static
std::string
createTempDirectory
()
throw
(
IOException
);
61
static
unsigned
long
fileSize
(
const
std::string& path)
throw
(
IOException
);
62
static
std::vector<std::string>
listFiles
(
const
std::string& directory,
bool
relative =
false
,
63
bool
listEmptyDirectories =
false
,
bool
unixStyle =
false
)
throw
(
IOException
);
64
static
void
copyFile
(
const
std::string& srcPath,
const
std::string& destPath,
bool
overwrite =
true
)
throw
(
IOException
);
65
static
void
moveFile
(
const
std::string& srcPath,
const
std::string& destPath,
bool
overwrite =
true
)
throw
(
IOException
);
66
static
void
removeFile
(
const
std::string& fname);
67
static
void
removeDirectory
(
const
std::string& fname);
68
static
void
deleteTempFiles
()
throw
(
IOException
);
69
static
void
removeDirectoryRecursively
(
const
std::string& dname)
throw
(
IOException
);
70
static
std::stack<std::string>
tempFiles
;
71
static
bool
compareUri
(
const
std::string &a,
const
std::string &b);
72
static
std::string
fromUri
(
const
std::string &uri);
73
static
std::string
toUri
(
const
std::string &path);
74
75
static
FILE*
fopen
(
const
std::string &
filename
,
const
std::string &
mode
);
76
77
private
:
78
static
std::vector<std::string>
getDirSubElements
(
const
std::string& directory,
bool
relative,
79
bool
filesOnly,
bool
unixStyle)
throw
(
IOException
);
80
#if !defined(_WIN32) && !defined(__APPLE__)
81
static
std::string
convertUTF8
(
const
std::string &str_in,
bool
to_UTF);
82
#endif
83
};
84
85
}
86
}
src
util
File.h
Generated on Tue Dec 18 2012 04:56:20 for libdigidocpp by
1.8.1.2