tio: implement SdCardObserver (finishes sysmodule)
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
#include "fsa/fs_mount_utils.hpp"
|
||||
#include "impl/fs_event_notifier_object_adapter.hpp"
|
||||
|
||||
namespace ams::fs {
|
||||
|
||||
@@ -87,4 +88,30 @@ namespace ams::fs {
|
||||
return fsa::Register(name, std::move(subdir_fs));
|
||||
}
|
||||
|
||||
Result OpenSdCardDetectionEventNotifier(std::unique_ptr<IEventNotifier> *out) {
|
||||
/* Try to open an event notifier. */
|
||||
FsEventNotifier notifier;
|
||||
AMS_FS_R_TRY(fsOpenSdCardDetectionEventNotifier(std::addressof(notifier)));
|
||||
|
||||
/* Create an event notifier adapter. */
|
||||
auto adapter = std::make_unique<impl::RemoteEventNotifierObjectAdapter>(notifier);
|
||||
R_UNLESS(adapter != nullptr, fs::ResultAllocationFailureInSdCardB());
|
||||
|
||||
*out = std::move(adapter);
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
bool IsSdCardInserted() {
|
||||
/* Open device operator. */
|
||||
FsDeviceOperator device_operator;
|
||||
AMS_FS_R_ABORT_UNLESS(::fsOpenDeviceOperator(std::addressof(device_operator)));
|
||||
ON_SCOPE_EXIT { ::fsDeviceOperatorClose(std::addressof(device_operator)); };
|
||||
|
||||
/* Get SD card inserted. */
|
||||
bool inserted;
|
||||
AMS_FS_R_ABORT_UNLESS(::fsDeviceOperatorIsSdCardInserted(std::addressof(device_operator), std::addressof(inserted)));
|
||||
|
||||
return inserted;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user