fs: add GetFileSystemAttribute cmd

This commit is contained in:
Pablo Curiel 2024-03-31 14:43:57 +02:00
parent 919e3d3938
commit 7509ce0832
2 changed files with 42 additions and 2 deletions

View File

@ -326,6 +326,38 @@ typedef enum {
FsFileSystemQueryId_IsValidSignedSystemPartitionOnSdCard = 2, ///< [8.0.0+] FsFileSystemQueryId_IsValidSignedSystemPartitionOnSdCard = 2, ///< [8.0.0+]
} FsFileSystemQueryId; } FsFileSystemQueryId;
/// FileSystemAttribute
typedef struct {
bool directory_name_length_max_has_value;
bool file_name_length_max_has_value;
bool directory_path_length_max_has_value;
bool file_path_length_max_has_value;
bool utf16_create_directory_path_length_max_has_value;
bool utf16_delete_directory_path_length_max_has_value;
bool utf16_rename_source_directory_path_length_max_has_value;
bool utf16_rename_destination_directory_path_length_max_has_value;
bool utf16_open_directory_path_length_max_has_value;
bool utf16_directory_name_length_max_has_value;
bool utf16_file_name_length_max_has_value;
bool utf16_directory_path_length_max_has_value;
bool utf16_file_path_length_max_has_value;
u8 reserved1[0x1B];
s32 directory_name_length_max;
s32 file_name_length_max;
s32 directory_path_length_max;
s32 file_path_length_max;
s32 utf16_create_directory_path_length_max;
s32 utf16_delete_directory_path_length_max;
s32 utf16_rename_source_directory_path_length_max;
s32 utf16_rename_destination_directory_path_length_max;
s32 utf16_open_directory_path_length_max;
s32 utf16_directory_name_length_max;
s32 utf16_file_name_length_max;
s32 utf16_directory_path_length_max;
s32 utf16_file_path_length_max;
u8 reserved2[0x64];
} FsFileSystemAttribute;
/// FsPriority /// FsPriority
typedef enum { typedef enum {
FsPriority_Normal = 0, FsPriority_Normal = 0,
@ -591,6 +623,7 @@ Result fsFsGetTotalSpace(FsFileSystem* fs, const char* path, s64* out);
Result fsFsGetFileTimeStampRaw(FsFileSystem* fs, const char* path, FsTimeStampRaw *out); ///< [3.0.0+] Result fsFsGetFileTimeStampRaw(FsFileSystem* fs, const char* path, FsTimeStampRaw *out); ///< [3.0.0+]
Result fsFsCleanDirectoryRecursively(FsFileSystem* fs, const char* path); ///< [3.0.0+] Result fsFsCleanDirectoryRecursively(FsFileSystem* fs, const char* path); ///< [3.0.0+]
Result fsFsQueryEntry(FsFileSystem* fs, void *out, size_t out_size, const void *in, size_t in_size, const char* path, FsFileSystemQueryId query_id); ///< [4.0.0+] Result fsFsQueryEntry(FsFileSystem* fs, void *out, size_t out_size, const void *in, size_t in_size, const char* path, FsFileSystemQueryId query_id); ///< [4.0.0+]
Result fsFsGetFileSystemAttribute(FsFileSystem* fs, FsFileSystemAttribute *out); ///< [15.0.0+]
void fsFsClose(FsFileSystem* fs); void fsFsClose(FsFileSystem* fs);
/// Uses \ref fsFsQueryEntry to set the archive bit on the specified absolute directory path. /// Uses \ref fsFsQueryEntry to set the archive bit on the specified absolute directory path.

View File

@ -937,6 +937,13 @@ Result fsFsQueryEntry(FsFileSystem* fs, void *out, size_t out_size, const void *
); );
} }
Result fsFsGetFileSystemAttribute(FsFileSystem* fs, FsFileSystemAttribute *out) {
if (hosversionBefore(15,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _fsObjectDispatchOut(&fs->s, 16, *out);
}
Result fsFsSetConcatenationFileAttribute(FsFileSystem* fs, const char *path) { Result fsFsSetConcatenationFileAttribute(FsFileSystem* fs, const char *path) {
return fsFsQueryEntry(fs, NULL, 0, NULL, 0, path, FsFileSystemQueryId_SetConcatenationFileAttribute); return fsFsQueryEntry(fs, NULL, 0, NULL, 0, path, FsFileSystemQueryId_SetConcatenationFileAttribute);
} }
@ -1231,7 +1238,7 @@ Result fsDeviceOperatorGetGameCardDeviceCertificate(FsDeviceOperator* d, const F
FsGameCardHandle handle; FsGameCardHandle handle;
s64 buffer_size; s64 buffer_size;
} in = { *handle, size }; } in = { *handle, size };
return _fsObjectDispatchIn(&d->s, 206, in, return _fsObjectDispatchIn(&d->s, 206, in,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out }, .buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { dst, dst_size } }); .buffers = { { dst, dst_size } });
@ -1256,7 +1263,7 @@ Result fsDeviceOperatorGetGameCardDeviceId(FsDeviceOperator* d, void* dst, size_
Result fsDeviceOperatorChallengeCardExistence(FsDeviceOperator* d, const FsGameCardHandle* handle, void* dst, size_t dst_size, void* seed, size_t seed_size, void* value, size_t value_size) { Result fsDeviceOperatorChallengeCardExistence(FsDeviceOperator* d, const FsGameCardHandle* handle, void* dst, size_t dst_size, void* seed, size_t seed_size, void* value, size_t value_size) {
if (hosversionBefore(8,0,0)) if (hosversionBefore(8,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _fsObjectDispatchIn(&d->s, 219, *handle, return _fsObjectDispatchIn(&d->s, 219, *handle,
.buffer_attrs = { .buffer_attrs = {
SfBufferAttr_HipcMapAlias | SfBufferAttr_Out, SfBufferAttr_HipcMapAlias | SfBufferAttr_Out,