Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
Directory.hpp
1 // Copyright (C) 2017 Jérôme Leclercq
2 // This file is part of the "Nazara Engine - Core module"
3 // For conditions of distribution and use, see copyright notice in Config.hpp
4 
5 #pragma once
6 
7 #ifndef NAZARA_DIRECTORY_HPP
8 #define NAZARA_DIRECTORY_HPP
9 
10 #include <Nazara/Prerequesites.hpp>
11 #include <Nazara/Core/MovablePtr.hpp>
12 #include <Nazara/Core/String.hpp>
13 
14 #if defined(NAZARA_PLATFORM_WINDOWS)
15  #define NAZARA_DIRECTORY_SEPARATOR '\\'
16 #elif defined(NAZARA_PLATFORM_LINUX)
17  #define NAZARA_DIRECTORY_SEPARATOR '/'
18 #else
19  #error OS not handled
20  #define NAZARA_DIRECTORY_SEPARATOR '/'
21 #endif
22 
23 #if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_DIRECTORY
24  #include <Nazara/Core/ThreadSafety.hpp>
25 #else
26  #include <Nazara/Core/ThreadSafetyOff.hpp>
27 #endif
28 
29 namespace Nz
30 {
31  class DirectoryImpl;
32 
33  class NAZARA_CORE_API Directory
34  {
35  public:
36  Directory();
37  Directory(const String& dirPath);
38  Directory(const Directory&) = delete;
39  Directory(Directory&&) noexcept = default;
40  ~Directory();
41 
42  void Close();
43 
44  bool Exists() const;
45 
46  String GetPath() const;
47  String GetPattern() const;
48  String GetResultName() const;
49  String GetResultPath() const;
50  UInt64 GetResultSize() const;
51 
52  bool IsOpen() const;
53  bool IsResultDirectory() const;
54 
55  bool NextResult(bool skipDots = true);
56 
57  bool Open();
58 
59  void SetPath(const String& dirPath);
60  void SetPattern(const String& pattern);
61 
62  static bool Copy(const String& sourcePath, const String& destPath);
63  static bool Create(const String& dirPath, bool recursive = false);
64  static bool Exists(const String& dirPath);
65  static String GetCurrent();
66  static const char* GetCurrentFileRelativeToEngine(const char* currentFile);
67  static bool Remove(const String& dirPath, bool emptyDirectory = false);
68  static bool SetCurrent(const String& dirPath);
69 
70  Directory& operator=(const Directory&) = delete;
71  Directory& operator=(Directory&&) noexcept = delete;
72 
73  private:
74  NazaraMutexAttrib(m_mutex, mutable)
75 
76  String m_dirPath;
77  String m_pattern;
79  };
80 }
81 
82 #endif // NAZARA_DIRECTORY_HPP
TODO: Inherit SoundEmitter from Node.
Definition: Algorithm.hpp:12
Core class that represents a string.
Definition: String.hpp:22
Core class that represents a directory.
Definition: Directory.hpp:33