Colobot
resourcemanager.h
1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsitec.ch; http://colobot.info; http://github.com/colobot
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see http://gnu.org/licenses
18  */
19 
20 #pragma once
21 
22 #include "common/resources/sdl_file_wrapper.h"
23 #include "common/resources/sdl_memory_wrapper.h"
24 #include "common/resources/sndfile_wrapper.h"
25 
26 #include <memory>
27 #include <string>
28 #include <vector>
29 
31 {
32 public:
33  CResourceManager(const char *argv0);
35 
36  static std::string CleanPath(const std::string &path);
37 
38  static bool AddLocation(const std::string &location, bool prepend = true);
39  static bool RemoveLocation(const std::string &location);
40 
41  static bool SetSaveLocation(const std::string &location);
42  static std::string GetSaveLocation();
43 
44  static std::unique_ptr<CSDLFileWrapper> GetSDLFileHandler(const std::string &filename);
45  static std::unique_ptr<CSDLMemoryWrapper> GetSDLMemoryHandler(const std::string &filename);
46  static std::unique_ptr<CSNDFileWrapper> GetSNDFileHandler(const std::string &filename);
47 
49  static bool Exists(const std::string &filename);
51  static bool DirectoryExists(const std::string& directory);
52 
54  static bool CreateDirectory(const std::string& directory);
56  static bool RemoveDirectory(const std::string& directory);
57 
59  static std::vector<std::string> ListFiles(const std::string &directory);
61  static std::vector<std::string> ListDirectories(const std::string &directory);
62 
63 
65  static long long GetFileSize(const std::string &filename);
67  static long long GetLastModificationTime(const std::string &filename);
68 
70  static bool Remove(const std::string& filename);
71 };
static bool DirectoryExists(const std::string &directory)
Check if file exists and is a directory.
Definition: resourcemanager.cpp:134
Definition: resourcemanager.h:30
static std::vector< std::string > ListDirectories(const std::string &directory)
List directories contained in directory.
Definition: resourcemanager.cpp:186
static std::vector< std::string > ListFiles(const std::string &directory)
List files contained in directory.
Definition: resourcemanager.cpp:167
static bool Exists(const std::string &filename)
Check if file exists.
Definition: resourcemanager.cpp:125
static long long GetLastModificationTime(const std::string &filename)
Returns last modification date as timestamp.
Definition: resourcemanager.cpp:222
static bool RemoveDirectory(const std::string &directory)
Remove directory in write directory, recursively.
Definition: resourcemanager.cpp:152
static long long GetFileSize(const std::string &filename)
Returns file size in bytes.
Definition: resourcemanager.cpp:209
static bool Remove(const std::string &filename)
Remove file.
Definition: resourcemanager.cpp:231
static bool CreateDirectory(const std::string &directory)
Create directory in write directory.
Definition: resourcemanager.cpp:143