diff --git a/src/core/file_sys/fs_path.h b/src/core/file_sys/fs_path.h index 1566e82b9d..92684ff4fa 100644 --- a/src/core/file_sys/fs_path.h +++ b/src/core/file_sys/fs_path.h @@ -143,20 +143,16 @@ public: return m_str; } - constexpr size_t GetLength() const { - if (std::is_constant_evaluated()) { - return Strlen(this->GetString()); - } else { - return std::strlen(this->GetString()); - } + size_t GetLength() const { + return std::strlen(this->GetString()); } constexpr bool IsEmpty() const { return *m_str == '\x00'; } - constexpr bool IsMatchHead(const char* p, size_t len) const { - return Strncmp(this->GetString(), p, len) == 0; + bool IsMatchHead(const char* p, size_t len) const { + return std::strncmp(this->GetString(), p, len) == 0; } Result Initialize(const Path& rhs) { @@ -169,7 +165,7 @@ public: R_TRY(this->Preallocate(len + 1)); // Copy the path - const size_t copied = Strlcpy(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); // Set normalized @@ -331,14 +327,14 @@ public: // Get our write buffer auto* dst = m_write_buffer.Get(); if (old_write_buffer.Get() != nullptr && cur_len > 0) { - Strlcpy(dst, old_write_buffer.Get(), cur_len + 1); + strlcpy(dst, old_write_buffer.Get(), cur_len + 1); } // Add separator dst[cur_len] = '/'; // Copy the child path - const size_t copied = Strlcpy(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_SUCCEED(); @@ -375,7 +371,7 @@ public: if (m_write_buffer.Get() == nullptr) { if (const auto len = std::strlen(m_str); len > 0) { R_TRY(this->Preallocate(len)); - Strlcpy(m_write_buffer.Get(), m_str, len + 1); + strlcpy(m_write_buffer.Get(), m_str, len + 1); } } @@ -497,7 +493,7 @@ private: R_TRY(this->Preallocate(size + 1)); // Copy the path - const size_t copied = Strlcpy(m_write_buffer.Get(), path, size + 1); + const size_t copied = strlcpy(m_write_buffer.Get(), path, size + 1); R_UNLESS(copied >= size, ResultUnexpectedInPathA); } else { // We can just clear the buffer diff --git a/src/core/file_sys/fs_path_utility.h b/src/core/file_sys/fs_path_utility.h index a18b54437c..3172bfc289 100644 --- a/src/core/file_sys/fs_path_utility.h +++ b/src/core/file_sys/fs_path_utility.h @@ -1217,7 +1217,7 @@ public: replaced_src = static_cast(Allocate(replaced_src_len)); } - Strlcpy(replaced_src, src, replaced_src_len); + strlcpy(replaced_src, src, replaced_src_len); Replace(replaced_src, replaced_src_len, AlternateDirectorySeparator, DirectorySeparator); diff --git a/src/core/file_sys/fs_string_util.h b/src/core/file_sys/fs_string_util.h index c751a8f1a2..4ec9aed8d3 100644 --- a/src/core/file_sys/fs_string_util.h +++ b/src/core/file_sys/fs_string_util.h @@ -7,85 +7,6 @@ namespace FileSys { -template -constexpr int Strlen(const T* str) { - ASSERT(str != nullptr); - - int length = 0; - while (*str++) { - ++length; - } - - return length; -} - -template -constexpr int Strnlen(const T* str, std::size_t count) { - return Strnlen(str, static_cast(count)); -} - -template -constexpr int Strnlen(const T* str, int count) { - ASSERT(str != nullptr); - ASSERT(count >= 0); - - int length = 0; - while (count-- && *str++) { - ++length; - } - - return length; -} - -template -constexpr int Strncmp(const T* lhs, const T* rhs, std::size_t count) { - return Strncmp(lhs, rhs, static_cast(count)); -} - -template -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 -static constexpr int Strlcpy(T* dst, const T* src, std::size_t count) { - return Strlcpy(dst, src, static_cast(count)); -} - -template -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(cur - src); -} - enum CharacterEncodingResult { CharacterEncodingResult_Success = 0, CharacterEncodingResult_InsufficientLength = 1,