* ams_mitm: add ability to mirror bluetooth device pairing database to sd card via a system setting
* ams_mitm: address requested stylistic changes
* ams_mitm: make use of R_SUCCEED macro
* ams_mitm: use settings::BluetoothDevicesSettings instead of libnx type
* ams_mitm: fix logic error when truncating pairing database on read
* Update .ini comment
* ams_mitm: missing R_TRY around call to fs::FlushFile
* stratosphere: remove union from BluetoothDevicesSettings type
---------
Co-authored-by: ndeadly <24677491+ndeadly@users.noreply.github.com>
* Setting retrieval was performed before the call that used the setting.
* Call to detect number of files passed incomplete path and was guaranteed to fail.
* Call to delete reports passed incomplete path and was guaranteed to do nothing.
This implements two optimizations on fs::Path, which N added in 12.0.0.
The current structure looks like:
```cpp
struct Path {
const char *m_str; // Points to the read-only path string
char *m_write_buffer_buffer; // Part of std::unique_ptr<char[], ams::fs::impl::Deleter>
ams::fs::impl::Deleter m_write_buffer_deleter; // Parse of std::unique_ptr<char[], ams::fs::impl::Deleter>, stores the size of the buffer.
size_t m_write_buffer_length; // Copy of the write buffer's size accessible to the Path() structure.
bool m_is_normalized; // Whether the path buffer is normalized
};
```
This is pretty wasteful. The write buffer size is stored twice, wasting 8 bytes, because one copy of the size isn't accessible to the path.
In addition, due to alignment, the bool wastes 7 padding bytes.
This commit:
* Encodes normalized in the low bit of the write buffer length, saving 8 bytes.
* Use a custom WriteBuffer class rather than generic unique_ptr, to avoid needing to store the WriteBuffer twice.
These each save 8 bytes, for a final size of 0x18 rather than 0x28.