nomlib
Loading...
Searching...
No Matches
IFile.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 NOMLIB_IFILE_HEADERS
30#define NOMLIB_IFILE_HEADERS
31
32#include <iostream>
33#include <string>
34#include <cstring>
35#include <vector>
36
37#include "nomlib/config.hpp"
38
39namespace nom {
40
42class IFile
43{
44 public:
45 IFile ( void ) {}
46 virtual ~IFile ( void ) {}
47
51 virtual const std::string extension ( const std::string& file ) = 0;
52
56 virtual int32 size ( const std::string& file_path ) = 0;
57
58 virtual bool is_dir( const std::string& file_path ) = 0;
59
60 virtual bool is_file( const std::string& file_path ) = 0;
61
63 virtual bool exists( const std::string& file_path ) = 0;
64
68 virtual const std::string path( const std::string& dir_path ) = 0;
69
73 virtual std::string currentPath( void ) = 0;
74
79 virtual bool set_path ( const std::string& path ) = 0;
80
87 virtual const std::string basename ( const std::string& filename ) = 0;
88
89 virtual std::vector<std::string> read_dir( const std::string& dir_path ) = 0;
90
91 virtual const std::string resource_path( const std::string& identifier = "\0" ) = 0;
92
93 virtual const std::string user_documents_path( void ) = 0;
94
95 virtual const std::string user_app_support_path( void ) = 0;
96
97 virtual const std::string user_home_path( void ) = 0;
98 virtual const std::string system_path( void ) = 0;
99
100 virtual bool mkdir( const std::string& path ) = 0;
101 virtual bool recursive_mkdir( const std::string& path ) = 0;
102 virtual bool rmdir( const std::string& path ) = 0;
103
104 virtual bool mkfile( const std::string& path ) = 0;
105
106 virtual std::string env( const std::string& path ) = 0;
107
111 virtual nom::size_type num_files(const std::string& path) = 0;
112};
113
114
115} // namespace nom
116
117#endif // include guard
118
virtual int32 size(const std::string &file_path)=0
virtual bool set_path(const std::string &path)=0
virtual bool exists(const std::string &file_path)=0
Uses stat(2) to determine if the input file exists.
virtual const std::string path(const std::string &dir_path)=0
Extract the directory portion of a pathname.
virtual std::string currentPath(void)=0
virtual const std::string extension(const std::string &file)=0
virtual const std::string basename(const std::string &filename)=0
virtual nom::size_type num_files(const std::string &path)=0
Get the total number of files in a directory.