nomlib
Toggle main menu visibility
Loading...
Searching...
No Matches
include
nomlib
system
File.hpp
1
/******************************************************************************
2
3
nomlib - C++11 cross-platform game engine
4
5
Copyright (c) 2013, 2014 Jeffrey Carpenter <i8degrees@gmail.com>
6
All rights reserved.
7
8
Redistribution and use in source and binary forms, with or without
9
modification, are permitted provided that the following conditions are met:
10
11
1. Redistributions of source code must retain the above copyright notice, this
12
list of conditions and the following disclaimer.
13
2. Redistributions in binary form must reproduce the above copyright notice,
14
this list of conditions and the following disclaimer in the documentation
15
and/or other materials provided with the distribution.
16
17
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28
******************************************************************************/
29
#ifndef NOMLIB_FILE_HEADERS
30
#define NOMLIB_FILE_HEADERS
31
32
#include <string>
33
#include <vector>
34
35
#include "export.hpp"
36
#include "nomlib/config.hpp"
37
#include "nomlib/system/IFile.hpp"
38
39
#if defined ( NOM_PLATFORM_OSX ) || defined ( NOM_PLATFORM_POSIX )
40
41
#include "nomlib/system/unix/UnixFile.hpp"
42
43
#elif defined ( NOM_PLATFORM_WINDOWS )
44
45
#include "nomlib/system/windows/WinFile.hpp"
46
47
#endif
48
49
namespace
nom {
50
51
// Forward declarations
52
class
IFile
;
53
55
class
NOM_EXPORT File
56
{
57
public
:
58
File();
59
~File();
60
62
std::string
extension
(
const
std::string& filename)
const
;
63
65
int32
size
(
const
std::string& file_path)
const
;
66
68
bool
is_dir
(
const
std::string& file_path)
const
;
69
70
bool
is_file(
const
std::string& file_path)
const
;
71
73
bool
exists
(
const
std::string& file_path)
const
;
74
78
std::string
path
(
const
std::string& dir_path)
const
;
79
81
std::string
currentPath
()
const
;
82
84
bool
set_path
(
const
std::string&
path
)
const
;
85
87
std::string
basename
(
const
std::string& filename)
const
;
88
89
std::vector<std::string> read_dir(
const
std::string& dir_path)
const
;
90
91
std::string resource_path(
const
std::string& identifier =
"\0"
)
const
;
92
93
std::string user_documents_path()
const
;
94
95
std::string user_app_support_path()
const
;
96
97
std::string user_home_path()
const
;
98
99
std::string system_path()
const
;
100
102
bool
mkdir
(
const
std::string&
path
)
const
;
103
105
bool
recursive_mkdir
(
const
std::string&
path
)
const
;
106
108
bool
rmdir
(
const
std::string&
path
)
const
;
109
111
bool
mkfile
(
const
std::string&
path
)
const
;
112
114
std::string
env
(
const
std::string&
path
)
const
;
115
117
nom::size_type
num_files
(
const
std::string&
path
)
const
;
118
119
private
:
120
std::unique_ptr<IFile> file;
121
};
122
123
namespace
priv {
124
126
NOM_EXPORT
extern
std::string file_root_;
127
128
}
// namespace priv
129
135
NOM_EXPORT std::string file_root();
136
145
NOM_EXPORT
void
set_file_root(
const
std::string& root);
146
147
}
// namespace nom
148
149
#endif
// include guard
150
nom::File::is_dir
bool is_dir(const std::string &file_path) const
Test for the existence of a directory.
nom::File::size
int32 size(const std::string &file_path) const
Re-implements nom::IFile::size.
nom::File::mkdir
bool mkdir(const std::string &path) const
nom::File::env
std::string env(const std::string &path) const
nom::File::exists
bool exists(const std::string &file_path) const
Re-implements nom::IFile::exists.
nom::File::extension
std::string extension(const std::string &filename) const
Re-implements nom::IFile::extension.
nom::File::mkfile
bool mkfile(const std::string &path) const
nom::File::recursive_mkdir
bool recursive_mkdir(const std::string &path) const
nom::File::path
std::string path(const std::string &dir_path) const
Platform-specific implementation of IFile::path.
nom::File::currentPath
std::string currentPath() const
Re-implements nom::IFile::currentPath.
nom::File::num_files
nom::size_type num_files(const std::string &path) const
nom::File::basename
std::string basename(const std::string &filename) const
Re-implements nom::IFile::basename.
nom::File::set_path
bool set_path(const std::string &path) const
Re-implements nom::IFile::set_path.
nom::File::rmdir
bool rmdir(const std::string &path) const
nom::IFile
Abstract interface class for Platform-agnostic file access.
Definition
IFile.hpp:44
Generated on
for nomlib by
1.18.0