mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-04 21:49:42 +00:00
openmw/apps/openmw/mwinput/controlswitch.hpp:32:49: error: ‘uint32_t’ has not been declared 32 | void readRecord(ESM::ESMReader& reader, uint32_t type); | ^~~~~~~~ openmw/apps/esmtool/labels.hpp:63:25: error: ‘uint32_t’ was not declared in this scope 63 | std::string recordFlags(uint32_t flags); | ^~~~~~~~ openmw/components/detournavigator/recastmesh.hpp:91:14: error: ‘uint8_t’ in namespace ‘std’ does not name a type; did you mean ‘wint_t’? 91 | std::uint8_t mLength; | ^~~~~~~ | wint_t openmw/components/platform/file.hpp:9:23: error: found ‘:’ in nested-name-specifier, expected ‘::’ 9 | enum class Handle : intptr_t | ^ | :: openmw/components/settings/settings.hpp:63:21: error: ‘int64_t’ in namespace ‘std’ does not name a type 63 | static std::int64_t getInt64(std::string_view setting, std::string_view category); | ^~~~~~~ openmw/components/esm/common.cpp:5:38: error: ‘uint32_t’ in namespace ‘std’ does not name a type; did you mean ‘wint_t’? 5 | std::string printName(const std::uint32_t typeId) | ^~~~~~~~ | wint_t
65 lines
1.5 KiB
C++
65 lines
1.5 KiB
C++
#ifndef OPENMW_COMPONENTS_PLATFORM_FILE_HPP
|
|
#define OPENMW_COMPONENTS_PLATFORM_FILE_HPP
|
|
|
|
#include <cstdlib>
|
|
#include <string_view>
|
|
#include <cstdint>
|
|
|
|
namespace Platform::File {
|
|
|
|
enum class Handle : intptr_t
|
|
{
|
|
Invalid = -1
|
|
};
|
|
|
|
enum class SeekType
|
|
{
|
|
Begin,
|
|
Current,
|
|
End
|
|
};
|
|
|
|
Handle open(const char* filename);
|
|
|
|
void close(Handle handle);
|
|
|
|
size_t size(Handle handle);
|
|
|
|
void seek(Handle handle, size_t Position, SeekType type = SeekType::Begin);
|
|
size_t tell(Handle handle);
|
|
|
|
size_t read(Handle handle, void* data, size_t size);
|
|
|
|
class ScopedHandle
|
|
{
|
|
Handle mHandle{ Handle::Invalid };
|
|
|
|
public:
|
|
ScopedHandle() noexcept = default;
|
|
ScopedHandle(ScopedHandle& other) = delete;
|
|
ScopedHandle(Handle handle) noexcept : mHandle(handle) {}
|
|
ScopedHandle(ScopedHandle&& other) noexcept
|
|
: mHandle(other.mHandle)
|
|
{
|
|
other.mHandle = Handle::Invalid;
|
|
}
|
|
ScopedHandle& operator=(const ScopedHandle& other) = delete;
|
|
ScopedHandle& operator=(ScopedHandle&& other) noexcept
|
|
{
|
|
if (mHandle != Handle::Invalid)
|
|
close(mHandle);
|
|
mHandle = other.mHandle;
|
|
other.mHandle = Handle::Invalid;
|
|
return *this;
|
|
}
|
|
~ScopedHandle()
|
|
{
|
|
if(mHandle != Handle::Invalid)
|
|
close(mHandle);
|
|
}
|
|
|
|
operator Handle() const { return mHandle; }
|
|
};
|
|
}
|
|
|
|
#endif // OPENMW_COMPONENTS_PLATFORM_FILE_HPP
|