nomlib
Loading...
Searching...
No Matches
WinFile.hpp
1/******************************************************************************
2
3 nomlib - C++11 cross-platform game engine
4
5Copyright (c) 2013, 2014 Jeffrey Carpenter <i8degrees@gmail.com>
6All rights reserved.
7
8Redistribution and use in source and binary forms, with or without
9modification, are permitted provided that the following conditions are met:
10
111. Redistributions of source code must retain the above copyright notice, this
12 list of conditions and the following disclaimer.
132. 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
17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24ON 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
26SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28******************************************************************************/
29#ifndef NOM_SYSTEM_WINDOWS_WIN_FILE_HPP
30#define NOM_SYSTEM_WINDOWS_WIN_FILE_HPP
31
32#include <string>
33#include <cstring>
34#include <vector>
35#include <fstream>
36
37#include <stdlib.h>
38#include <errno.h>
39#include <direct.h>
40
41#include "export.hpp"
42#include "nomlib/config.hpp"
43#include "nomlib/system/IFile.hpp"
44
45namespace nom {
46
48class NOM_EXPORT WinFile: public IFile
49{
50 public:
51 WinFile ( void );
52 ~WinFile ( void );
53
57 const std::string extension ( const std::string& file );
58
62 int32 size( const std::string& file_path );
63
67 bool is_dir( const std::string& file_path );
68
69 bool is_file( const std::string& file_path );
70
77 bool exists( const std::string& file_path );
78
88 const std::string path( const std::string& dir_path );
89
96 std::string currentPath( void );
97
101 bool set_path ( const std::string& path );
102
106 const std::string basename ( const std::string& filename );
107
116 std::vector<std::string> read_dir( const std::string& dir_path );
117
129 const std::string resource_path( const std::string& identifier = "\0" );
130
143 const std::string user_documents_path( void );
144
157 const std::string user_app_support_path( void );
158
166 const std::string user_home_path( void );
167
175 const std::string system_path( void );
176
177 // TODO: Implement getter method for platform's system temporary files path;
178 // (/tmp on POSIX and C:\Windows\Temp on Windows).
179 // const std::string system_temp_path( void );
180
194 bool mkdir( const std::string& path );
195
208 bool recursive_mkdir( const std::string& path );
209
223 bool rmdir( const std::string& path );
224
225 bool mkfile( const std::string& path );
226
233 std::string env( const std::string& path );
234
235 nom::size_type num_files(const std::string& path);
236};
237
238
239} // namespace nom
240
241#endif // include guard
242
std::vector< std::string > read_dir(const std::string &dir_path)
Get a list of file entries within a directory.
bool set_path(const std::string &path)
const std::string extension(const std::string &file)
bool mkdir(const std::string &path)
Create a directory entry.
const std::string user_home_path(void)
Get the current user's home directory path.
std::string env(const std::string &path)
Get the value of an environment variable.
nom::size_type num_files(const std::string &path)
Get the total number of files in a directory.
const std::string user_documents_path(void)
bool is_dir(const std::string &file_path)
Test for the existence of a directory.
bool recursive_mkdir(const std::string &path)
Create directories recursively.
const std::string path(const std::string &dir_path)
Extract the directory portion of a pathname.
bool rmdir(const std::string &path)
Remove a directory entry.
const std::string system_path(void)
Get the platform-defined system path.
const std::string resource_path(const std::string &identifier="\0")
Get the path to the Resources folder.
std::string currentPath(void)
const std::string basename(const std::string &filename)
const std::string user_app_support_path(void)
int32 size(const std::string &file_path)
bool exists(const std::string &file_path)