2020-04-04 05:40:46 +00:00
|
|
|
/*
|
2021-10-04 19:59:10 +00:00
|
|
|
* Copyright (c) Atmosphère-NX
|
2020-04-04 05:40:46 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <stratosphere/ncm/ncm_storage_id.hpp>
|
|
|
|
#include <stratosphere/ncm/ncm_content_meta_id.hpp>
|
|
|
|
|
|
|
|
namespace ams::ncm {
|
|
|
|
|
|
|
|
class StorageList {
|
|
|
|
public:
|
|
|
|
static constexpr s32 MaxCount = 10;
|
|
|
|
private:
|
2021-10-10 07:14:06 +00:00
|
|
|
StorageId m_ids[MaxCount];
|
|
|
|
s32 m_count;
|
2020-04-04 05:40:46 +00:00
|
|
|
public:
|
2021-10-10 07:14:06 +00:00
|
|
|
constexpr StorageList() : m_ids(), m_count() { /* ... */ }
|
2020-04-04 05:40:46 +00:00
|
|
|
|
|
|
|
void Push(StorageId storage_id) {
|
2021-10-10 07:14:06 +00:00
|
|
|
AMS_ABORT_UNLESS(m_count < MaxCount);
|
2020-04-04 05:40:46 +00:00
|
|
|
|
|
|
|
for (s32 i = 0; i < MaxCount; i++) {
|
2021-10-10 07:14:06 +00:00
|
|
|
if (m_ids[i] == storage_id) {
|
2020-04-04 05:40:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-10 07:14:06 +00:00
|
|
|
m_ids[m_count++] = storage_id;
|
2020-04-04 05:40:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
s32 Count() const {
|
2021-10-10 07:14:06 +00:00
|
|
|
return m_count;
|
2020-04-04 05:40:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StorageId operator[](s32 i) const {
|
2021-10-10 07:14:06 +00:00
|
|
|
AMS_ABORT_UNLESS(i < m_count);
|
|
|
|
return m_ids[i];
|
2020-04-04 05:40:46 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr StorageList GetStorageList(StorageId storage_id) {
|
|
|
|
StorageList list;
|
|
|
|
switch (storage_id) {
|
|
|
|
case StorageId::BuiltInSystem:
|
|
|
|
case StorageId::BuiltInUser:
|
|
|
|
case StorageId::SdCard:
|
|
|
|
list.Push(storage_id);
|
|
|
|
break;
|
|
|
|
case StorageId::Any:
|
|
|
|
list.Push(StorageId::SdCard);
|
|
|
|
list.Push(StorageId::BuiltInUser);
|
|
|
|
break;
|
|
|
|
AMS_UNREACHABLE_DEFAULT_CASE();
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
Result SelectDownloadableStorage(StorageId *out_storage_id, StorageId storage_id, s64 required_size);
|
|
|
|
Result SelectPatchStorage(StorageId *out_storage_id, StorageId storage_id, PatchId patch_id);
|
|
|
|
const char *GetStorageIdString(StorageId storage_id);
|
|
|
|
const char *GetStorageIdStringForPlayReport(StorageId storage_id);
|
|
|
|
|
|
|
|
}
|