Big f***ing cleanup part 1

This commit is contained in:
Lynix
2020-02-23 00:42:22 +01:00
parent 67d0e0a689
commit 3d22321109
178 changed files with 2190 additions and 5113 deletions

View File

@@ -13,14 +13,9 @@
#include <Nazara/Core/MovablePtr.hpp>
#include <Nazara/Core/Stream.hpp>
#include <Nazara/Core/String.hpp>
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_FILE
#include <Nazara/Core/ThreadSafety.hpp>
#else
#include <Nazara/Core/ThreadSafetyOff.hpp>
#endif
#include <ctime>
#include <filesystem>
#include <fstream>
namespace Nz
{
@@ -30,13 +25,13 @@ namespace Nz
{
public:
File();
File(const String& filePath);
File(const String& filePath, OpenModeFlags openMode);
File(const std::filesystem::path& filePath);
File(const std::filesystem::path& filePath, OpenModeFlags openMode);
File(const File&) = delete;
File(File&& file) noexcept = default;
File(File&& file) noexcept;
~File();
bool Copy(const String& newFilePath);
void Copy(const std::filesystem::path& newFilePath);
void Close();
bool Delete();
@@ -46,56 +41,35 @@ namespace Nz
bool Exists() const;
time_t GetCreationTime() const;
UInt64 GetCursorPos() const override;
String GetDirectory() const override;
String GetFileName() const;
time_t GetLastAccessTime() const;
time_t GetLastWriteTime() const;
String GetPath() const override;
std::filesystem::path GetDirectory() const override;
std::filesystem::path GetFileName() const;
std::filesystem::path GetPath() const override;
UInt64 GetSize() const override;
bool IsOpen() const;
bool Open(OpenModeFlags openMode = OpenMode_NotOpen);
bool Open(const String& filePath, OpenModeFlags openMode = OpenMode_NotOpen);
bool Rename(const String& newFilePath);
bool Open(const std::filesystem::path& filePath, OpenModeFlags openMode = OpenMode_NotOpen);
bool SetCursorPos(CursorPosition pos, Int64 offset = 0);
bool SetCursorPos(UInt64 offset) override;
bool SetFile(const String& filePath);
bool SetFile(const std::filesystem::path& filePath);
bool SetSize(UInt64 size);
File& operator=(const String& filePath);
File& operator=(const File&) = delete;
File& operator=(File&& file) noexcept = default;
File& operator=(File&& file) noexcept;
static String AbsolutePath(const String& filePath);
static inline ByteArray ComputeHash(HashType hash, const String& filePath);
static inline ByteArray ComputeHash(AbstractHash* hash, const String& filePath);
static bool Copy(const String& sourcePath, const String& targetPath);
static bool Delete(const String& filePath);
static bool Exists(const String& filePath);
static time_t GetCreationTime(const String& filePath);
static String GetDirectory(const String& filePath);
static time_t GetLastAccessTime(const String& filePath);
static time_t GetLastWriteTime(const String& filePath);
static UInt64 GetSize(const String& filePath);
static bool IsAbsolute(const String& filePath);
static String NormalizePath(const String& filePath);
static String NormalizeSeparators(const String& filePath);
static bool Rename(const String& sourcePath, const String& targetPath);
static inline ByteArray ComputeHash(HashType hash, const std::filesystem::path& filePath);
static inline ByteArray ComputeHash(AbstractHash* hash, const std::filesystem::path& filePath);
private:
NazaraMutexAttrib(m_mutex, mutable)
void FlushStream() override;
std::size_t ReadBlock(void* buffer, std::size_t size) override;
std::size_t WriteBlock(const void* buffer, std::size_t size) override;
String m_filePath;
MovablePtr<FileImpl> m_impl;
std::filesystem::path m_filePath;
std::unique_ptr<FileImpl> m_impl;
};
NAZARA_CORE_API bool HashAppend(AbstractHash* hash, const File& originalFile);