mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-10-09 14:53:19 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| da391ca89b | |||
| b9ef5bb83b |
+12
-13
@@ -1,3 +1,6 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
@@ -143,20 +146,16 @@ public:
|
|||||||
return m_str;
|
return m_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr size_t GetLength() const {
|
size_t GetLength() const {
|
||||||
if (std::is_constant_evaluated()) {
|
return std::strlen(this->GetString());
|
||||||
return Strlen(this->GetString());
|
|
||||||
} else {
|
|
||||||
return std::strlen(this->GetString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr bool IsEmpty() const {
|
constexpr bool IsEmpty() const {
|
||||||
return *m_str == '\x00';
|
return *m_str == '\x00';
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr bool IsMatchHead(const char* p, size_t len) const {
|
bool IsMatchHead(const char* p, size_t len) const {
|
||||||
return Strncmp(this->GetString(), p, len) == 0;
|
return std::strncmp(this->GetString(), p, len) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result Initialize(const Path& rhs) {
|
Result Initialize(const Path& rhs) {
|
||||||
@@ -169,7 +168,7 @@ public:
|
|||||||
R_TRY(this->Preallocate(len + 1));
|
R_TRY(this->Preallocate(len + 1));
|
||||||
|
|
||||||
// Copy the path
|
// Copy the path
|
||||||
const size_t copied = Strlcpy<char>(m_write_buffer.Get(), rhs.GetString(), len + 1);
|
const size_t copied = strlcpy(m_write_buffer.Get(), rhs.GetString(), len + 1);
|
||||||
R_UNLESS(copied == len, ResultUnexpectedInPathA);
|
R_UNLESS(copied == len, ResultUnexpectedInPathA);
|
||||||
|
|
||||||
// Set normalized
|
// Set normalized
|
||||||
@@ -331,14 +330,14 @@ public:
|
|||||||
// Get our write buffer
|
// Get our write buffer
|
||||||
auto* dst = m_write_buffer.Get();
|
auto* dst = m_write_buffer.Get();
|
||||||
if (old_write_buffer.Get() != nullptr && cur_len > 0) {
|
if (old_write_buffer.Get() != nullptr && cur_len > 0) {
|
||||||
Strlcpy<char>(dst, old_write_buffer.Get(), cur_len + 1);
|
strlcpy(dst, old_write_buffer.Get(), cur_len + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add separator
|
// Add separator
|
||||||
dst[cur_len] = '/';
|
dst[cur_len] = '/';
|
||||||
|
|
||||||
// Copy the child path
|
// Copy the child path
|
||||||
const size_t copied = Strlcpy<char>(dst + cur_len + 1, c, child_len + 1);
|
const size_t copied = strlcpy(dst + cur_len + 1, c, child_len + 1);
|
||||||
R_UNLESS(copied == child_len, ResultUnexpectedInPathA);
|
R_UNLESS(copied == child_len, ResultUnexpectedInPathA);
|
||||||
|
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
@@ -375,7 +374,7 @@ public:
|
|||||||
if (m_write_buffer.Get() == nullptr) {
|
if (m_write_buffer.Get() == nullptr) {
|
||||||
if (const auto len = std::strlen(m_str); len > 0) {
|
if (const auto len = std::strlen(m_str); len > 0) {
|
||||||
R_TRY(this->Preallocate(len));
|
R_TRY(this->Preallocate(len));
|
||||||
Strlcpy<char>(m_write_buffer.Get(), m_str, len + 1);
|
strlcpy(m_write_buffer.Get(), m_str, len + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,7 +496,7 @@ private:
|
|||||||
R_TRY(this->Preallocate(size + 1));
|
R_TRY(this->Preallocate(size + 1));
|
||||||
|
|
||||||
// Copy the path
|
// Copy the path
|
||||||
const size_t copied = Strlcpy<char>(m_write_buffer.Get(), path, size + 1);
|
const size_t copied = strlcpy(m_write_buffer.Get(), path, size + 1);
|
||||||
R_UNLESS(copied >= size, ResultUnexpectedInPathA);
|
R_UNLESS(copied >= size, ResultUnexpectedInPathA);
|
||||||
} else {
|
} else {
|
||||||
// We can just clear the buffer
|
// We can just clear the buffer
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||||
@@ -1217,7 +1217,7 @@ public:
|
|||||||
replaced_src = static_cast<char*>(Allocate(replaced_src_len));
|
replaced_src = static_cast<char*>(Allocate(replaced_src_len));
|
||||||
}
|
}
|
||||||
|
|
||||||
Strlcpy<char>(replaced_src, src, replaced_src_len);
|
strlcpy(replaced_src, src, replaced_src_len);
|
||||||
|
|
||||||
Replace(replaced_src, replaced_src_len, AlternateDirectorySeparator,
|
Replace(replaced_src, replaced_src_len, AlternateDirectorySeparator,
|
||||||
DirectorySeparator);
|
DirectorySeparator);
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
@@ -7,85 +10,6 @@
|
|||||||
|
|
||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
constexpr int Strlen(const T* str) {
|
|
||||||
ASSERT(str != nullptr);
|
|
||||||
|
|
||||||
int length = 0;
|
|
||||||
while (*str++) {
|
|
||||||
++length;
|
|
||||||
}
|
|
||||||
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
constexpr int Strnlen(const T* str, std::size_t count) {
|
|
||||||
return Strnlen(str, static_cast<int>(count));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
constexpr int Strnlen(const T* str, int count) {
|
|
||||||
ASSERT(str != nullptr);
|
|
||||||
ASSERT(count >= 0);
|
|
||||||
|
|
||||||
int length = 0;
|
|
||||||
while (count-- && *str++) {
|
|
||||||
++length;
|
|
||||||
}
|
|
||||||
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
constexpr int Strncmp(const T* lhs, const T* rhs, std::size_t count) {
|
|
||||||
return Strncmp(lhs, rhs, static_cast<int>(count));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
constexpr int Strncmp(const T* lhs, const T* rhs, int count) {
|
|
||||||
ASSERT(lhs != nullptr);
|
|
||||||
ASSERT(rhs != nullptr);
|
|
||||||
ASSERT(count >= 0);
|
|
||||||
|
|
||||||
if (count == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
T l, r;
|
|
||||||
do {
|
|
||||||
l = *(lhs++);
|
|
||||||
r = *(rhs++);
|
|
||||||
} while (l && (l == r) && (--count));
|
|
||||||
|
|
||||||
return l - r;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
static constexpr int Strlcpy(T* dst, const T* src, std::size_t count) {
|
|
||||||
return Strlcpy<T>(dst, src, static_cast<int>(count));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
static constexpr int Strlcpy(T* dst, const T* src, int count) {
|
|
||||||
ASSERT(dst != nullptr);
|
|
||||||
ASSERT(src != nullptr);
|
|
||||||
|
|
||||||
const T* cur = src;
|
|
||||||
if (count > 0) {
|
|
||||||
while ((--count) && *cur) {
|
|
||||||
*(dst++) = *(cur++);
|
|
||||||
}
|
|
||||||
*dst = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (*cur) {
|
|
||||||
cur++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return static_cast<int>(cur - src);
|
|
||||||
}
|
|
||||||
|
|
||||||
enum CharacterEncodingResult {
|
enum CharacterEncodingResult {
|
||||||
CharacterEncodingResult_Success = 0,
|
CharacterEncodingResult_Success = 0,
|
||||||
CharacterEncodingResult_InsufficientLength = 1,
|
CharacterEncodingResult_InsufficientLength = 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user