// Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once #ifndef NAZARA_FILE_HPP #define NAZARA_FILE_HPP #include #include #include #include #include #include #include #include #if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_FILE #include #else #include #endif #include namespace Nz { class FileImpl; class NAZARA_CORE_API File : public Hashable, public InputStream { public: File(); File(const String& filePath); File(const String& filePath, unsigned int openMode); File(const File&) = delete; File(File&& file) noexcept; ~File(); bool Copy(const String& newFilePath); void Close(); bool Delete(); bool EndOfFile() const; bool EndOfStream() const; bool Exists() const; void Flush(); time_t GetCreationTime() const; UInt64 GetCursorPos() const; String GetDirectory() const; String GetFileName() const; time_t GetLastAccessTime() const; time_t GetLastWriteTime() const; String GetPath() const; UInt64 GetSize() const; bool IsOpen() const; bool Open(unsigned int openMode = OpenMode_Current); bool Open(const String& filePath, unsigned int openMode = OpenMode_Current); std::size_t Read(void* buffer, std::size_t size); std::size_t Read(void* buffer, std::size_t typeSize, unsigned int count); bool Rename(const String& newFilePath); bool SetCursorPos(CursorPosition pos, Int64 offset = 0); bool SetCursorPos(UInt64 offset); void SetEndianness(Endianness endianness); bool SetFile(const String& filePath); bool SetOpenMode(unsigned int openMode); bool Write(const Nz::ByteArray& byteArray); bool Write(const String& string); std::size_t Write(const void* buffer, std::size_t typeSize, unsigned int count); File& operator=(const String& filePath); File& operator=(const File&) = delete; File& operator=(File&& file) noexcept; static String AbsolutePath(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 HashDigest GetHash(const String& filePath, HashType hash); static HashDigest GetHash(const String& filePath, AbstractHash* hash); 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); private: bool FillHash(AbstractHash* hash) const; NazaraMutexAttrib(m_mutex, mutable) Endianness m_endianness; String m_filePath; FileImpl* m_impl; unsigned int m_openMode; }; } #endif // NAZARA_FILE_HPP