2021-12-14 06:42:32 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) Atmosphère-NX
|
|
|
|
*
|
|
|
|
* 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 <vapours.hpp>
|
|
|
|
|
|
|
|
namespace ams::fssystem {
|
|
|
|
|
2022-03-12 21:03:17 +00:00
|
|
|
enum CompressionType : u8 {
|
2021-12-14 06:42:32 +00:00
|
|
|
CompressionType_None = 0,
|
2022-03-12 21:03:17 +00:00
|
|
|
CompressionType_Zeros = 1,
|
2021-12-14 06:42:32 +00:00
|
|
|
CompressionType_2 = 2,
|
|
|
|
CompressionType_Lz4 = 3,
|
|
|
|
CompressionType_Unknown = 4,
|
|
|
|
};
|
|
|
|
|
|
|
|
using DecompressorFunction = Result (*)(void *, size_t, const void *, size_t);
|
|
|
|
using GetDecompressorFunction = DecompressorFunction (*)(CompressionType);
|
|
|
|
|
2022-03-12 21:03:17 +00:00
|
|
|
constexpr s64 CompressionBlockAlignment = 0x10;
|
|
|
|
|
2021-12-14 06:42:32 +00:00
|
|
|
namespace CompressionTypeUtility {
|
|
|
|
|
|
|
|
constexpr bool IsBlockAlignmentRequired(CompressionType type) {
|
2022-03-12 21:03:17 +00:00
|
|
|
return type != CompressionType_None && type != CompressionType_Zeros;
|
2021-12-14 06:42:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
constexpr bool IsDataStorageAccessRequired(CompressionType type) {
|
2022-03-12 21:03:17 +00:00
|
|
|
return type != CompressionType_Zeros;
|
2021-12-14 06:42:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
constexpr bool IsRandomAccessible(CompressionType type) {
|
2021-12-14 16:51:27 +00:00
|
|
|
return type == CompressionType_None;
|
2021-12-14 06:42:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
constexpr bool IsUnknownType(CompressionType type) {
|
|
|
|
return type >= CompressionType_Unknown;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|