Apply clang-format to code base

This commit is contained in:
clang-format-bot 2022-09-22 21:26:05 +03:00 committed by ζeh Matt
parent f37d0be806
commit ddb0522bbf
No known key found for this signature in database
GPG key ID: 18CE582C71A225B0
2199 changed files with 118692 additions and 114392 deletions

View file

@ -4,7 +4,8 @@
#include <cstdlib>
#include <filesystem>
namespace Platform::File {
namespace Platform::File
{
enum class Handle : intptr_t
{
@ -32,15 +33,18 @@ namespace Platform::File {
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(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
@ -51,10 +55,10 @@ namespace Platform::File {
other.mHandle = Handle::Invalid;
return *this;
}
~ScopedHandle()
{
if(mHandle != Handle::Invalid)
close(mHandle);
~ScopedHandle()
{
if (mHandle != Handle::Invalid)
close(mHandle);
}
operator Handle() const { return mHandle; }

View file

@ -1,17 +1,18 @@
#include "file.hpp"
#include <cassert>
#include <errno.h>
#include <fcntl.h>
#include <stdexcept>
#include <string.h>
#include <string>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <stdexcept>
#include <string>
#include <cassert>
#include <components/files/conversion.hpp>
namespace Platform::File {
namespace Platform::File
{
static auto getNativeHandle(Handle handle)
{
@ -42,7 +43,8 @@ namespace Platform::File {
auto handle = ::open(filename.c_str(), openFlags, 0);
if (handle == -1)
{
throw std::runtime_error(std::string("Failed to open '") + Files::pathToUnicodeString(filename) + "' for reading: " + strerror(errno));
throw std::runtime_error(std::string("Failed to open '") + Files::pathToUnicodeString(filename)
+ "' for reading: " + strerror(errno));
}
return static_cast<Handle>(handle);
}
@ -73,7 +75,6 @@ namespace Platform::File {
const auto fileSize = tell(handle);
seek(handle, oldPos, SeekType::Begin);
return static_cast<size_t>(fileSize);
}
@ -96,7 +97,8 @@ namespace Platform::File {
int amount = ::read(nativeHandle, data, size);
if (amount == -1)
{
throw std::runtime_error("An attempt to read " + std::to_string(size) + " bytes failed: " + strerror(errno));
throw std::runtime_error(
"An attempt to read " + std::to_string(size) + " bytes failed: " + strerror(errno));
}
return amount;
}

View file

@ -1,14 +1,15 @@
#include "file.hpp"
#include <cassert>
#include <errno.h>
#include <stdexcept>
#include <string.h>
#include <string>
#include <stdexcept>
#include <cassert>
#include <components/files/conversion.hpp>
namespace Platform::File {
namespace Platform::File
{
static auto getNativeHandle(Handle handle)
{
@ -33,7 +34,8 @@ namespace Platform::File {
FILE* handle = fopen(filename.c_str(), "rb");
if (handle == nullptr)
{
throw std::runtime_error(std::string("Failed to open '") + Files::pathToUnicodeString(filename) + "' for reading: " + strerror(errno));
throw std::runtime_error(std::string("Failed to open '") + Files::pathToUnicodeString(filename)
+ "' for reading: " + strerror(errno));
}
return static_cast<Handle>(reinterpret_cast<intptr_t>(handle));
}
@ -57,7 +59,7 @@ namespace Platform::File {
size_t size(Handle handle)
{
auto nativeHandle = getNativeHandle(handle);
const auto oldPos = tell(handle);
seek(handle, 0, SeekType::End);
const auto fileSize = tell(handle);
@ -85,7 +87,8 @@ namespace Platform::File {
int amount = fread(data, 1, size, nativeHandle);
if (amount == 0 && ferror(nativeHandle))
{
throw std::runtime_error(std::string("An attempt to read ") + std::to_string(size) + " bytes failed: " + strerror(errno));
throw std::runtime_error(
std::string("An attempt to read ") + std::to_string(size) + " bytes failed: " + strerror(errno));
}
return static_cast<size_t>(amount);
}

View file

@ -1,14 +1,15 @@
#include "file.hpp"
#include <components/windows.hpp>
#include <string>
#include <stdexcept>
#include <boost/locale.hpp>
#include <cassert>
#include <components/windows.hpp>
#include <stdexcept>
#include <string>
#include <components/files/conversion.hpp>
namespace Platform::File {
namespace Platform::File
{
static auto getNativeHandle(Handle handle)
{
@ -33,7 +34,8 @@ namespace Platform::File {
HANDLE handle = CreateFileW(filename.c_str(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if (handle == INVALID_HANDLE_VALUE)
{
throw std::runtime_error(std::string("Failed to open '") + Files::pathToUnicodeString(filename) + "' for reading: " + std::to_string(GetLastError()));
throw std::runtime_error(std::string("Failed to open '") + Files::pathToUnicodeString(filename)
+ "' for reading: " + std::to_string(GetLastError()));
}
return static_cast<Handle>(reinterpret_cast<intptr_t>(handle));
}
@ -49,7 +51,8 @@ namespace Platform::File {
const auto nativeHandle = getNativeHandle(handle);
const auto nativeSeekType = getNativeSeekType(type);
if (SetFilePointer(nativeHandle, static_cast<LONG>(position), nullptr, nativeSeekType) == INVALID_SET_FILE_POINTER)
if (SetFilePointer(nativeHandle, static_cast<LONG>(position), nullptr, nativeSeekType)
== INVALID_SET_FILE_POINTER)
{
if (auto errCode = GetLastError(); errCode != ERROR_SUCCESS)
{
@ -91,7 +94,8 @@ namespace Platform::File {
DWORD bytesRead{};
if (!ReadFile(nativeHandle, data, static_cast<DWORD>(size), &bytesRead, nullptr))
throw std::runtime_error(std::string("A read operation on a file failed: ") + std::to_string(GetLastError()));
throw std::runtime_error(
std::string("A read operation on a file failed: ") + std::to_string(GetLastError()));
return bytesRead;
}

View file

@ -2,7 +2,8 @@
#include <stdio.h>
namespace Platform {
namespace Platform
{
static void increaseFileHandleLimit()
{

View file

@ -1,7 +1,8 @@
#ifndef OPENMW_COMPONENTS_PLATFORM_PLATFORM_HPP
#define OPENMW_COMPONENTS_PLATFORM_PLATFORM_HPP
namespace Platform {
namespace Platform
{
void init();