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 "nomlib/config.hpp"
42#include "nomlib/system/IFile.hpp"
43
44namespace nom {
45
47class WinFile: public IFile
48{
49 public:
50 WinFile ( void );
51 ~WinFile ( void );
52
56 const std::string extension ( const std::string& file );
57
61 int32 size( const std::string& file_path );
62
66 bool is_dir( const std::string& file_path );
67
68 bool is_file( const std::string& file_path );
69
76 bool exists( const std::string& file_path );
77
87 const std::string path( const std::string& dir_path );
88
95 std::string currentPath( void );
96
100 bool set_path ( const std::string& path );
101
105 const std::string basename ( const std::string& filename );
106
115 std::vector<std::string> read_dir( const std::string& dir_path );
116
128 const std::string resource_path( const std::string& identifier = "\0" );
129
142 const std::string user_documents_path( void );
143
156 const std::string user_app_support_path( void );
157
165 const std::string user_home_path( void );
166
174 const std::string system_path( void );
175
176 // TODO: Implement getter method for platform's system temporary files path;
177 // (/tmp on POSIX and C:\Windows\Temp on Windows).
178 // const std::string system_temp_path( void );
179
193 bool mkdir( const std::string& path );
194
207 bool recursive_mkdir( const std::string& path );
208
222 bool rmdir( const std::string& path );
223
224 bool mkfile( const std::string& path );
225
232 std::string env( const std::string& path );
233
234 nom::size_type num_files(const std::string& path);
235};
236
237
238} // namespace nom
239
240#endif // include guard
241
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)