fs: preserve ReleaseBuffer return type

This commit is contained in:
Michael Scire 2022-03-24 20:21:14 -07:00
commit df031e5280

View file

@ -62,6 +62,12 @@ namespace ams::fs {
return *this; return *this;
} }
std::unique_ptr<char[], ::ams::fs::impl::Deleter> ReleaseBuffer() {
auto released = std::unique_ptr<char[], ::ams::fs::impl::Deleter>(m_buffer, ::ams::fs::impl::Deleter(this->GetLength()));
this->ResetBuffer();
return released;
}
constexpr ALWAYS_INLINE void ResetBuffer() { constexpr ALWAYS_INLINE void ResetBuffer() {
m_buffer = nullptr; m_buffer = nullptr;
this->SetLength(0); this->SetLength(0);
@ -118,15 +124,15 @@ namespace ams::fs {
constexpr ~Path() { /* ... */ } constexpr ~Path() { /* ... */ }
WriteBuffer ReleaseBuffer() { std::unique_ptr<char[], ::ams::fs::impl::Deleter> ReleaseBuffer() {
/* Check pre-conditions. */ /* Check pre-conditions. */
AMS_ASSERT(m_write_buffer.Get() != nullptr); AMS_ASSERT(m_write_buffer.Get() != nullptr);
/* Reset. */ /* Reset. */
m_str = EmptyPath; m_str = EmptyPath;
/* Return our write buffer. */ /* Release our write buffer. */
return std::move(m_write_buffer); return m_write_buffer.ReleaseBuffer();
} }
constexpr Result SetShallowBuffer(const char *buffer) { constexpr Result SetShallowBuffer(const char *buffer) {