diff --git a/libraries/libstratosphere/include/stratosphere/tma.hpp b/libraries/libstratosphere/include/stratosphere/tma.hpp index 2174693ea..a643a7baf 100644 --- a/libraries/libstratosphere/include/stratosphere/tma.hpp +++ b/libraries/libstratosphere/include/stratosphere/tma.hpp @@ -17,3 +17,4 @@ #include #include +#include diff --git a/libraries/libstratosphere/include/stratosphere/tma/tma_i_directory_accessor.hpp b/libraries/libstratosphere/include/stratosphere/tma/tma_i_directory_accessor.hpp new file mode 100644 index 000000000..1347ac6c2 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/tma/tma_i_directory_accessor.hpp @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2018-2020 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 . + */ +#pragma once +#include +#include +#include + +/* NOTE: Minimum firmware version not enforced for any commands. */ +#define AMS_TMA_I_DIRECTORY_ACCESSOR_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, GetEntryCount, (ams::sf::Out out), (out)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, Read, (ams::sf::Out out, const ams::sf::OutMapAliasArray &out_entries), (out, out_entries)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, SetPriorityForDirectory, (s32 priority), (priority)) \ + AMS_SF_METHOD_INFO(C, H, 3, Result, GetPriorityForDirectory, (ams::sf::Out out), (out)) + +AMS_SF_DEFINE_INTERFACE(ams::tma, IDirectoryAccessor, AMS_TMA_I_DIRECTORY_ACCESSOR_INTERFACE_INFO) diff --git a/libraries/libstratosphere/include/stratosphere/tma/tma_i_file_accessor.hpp b/libraries/libstratosphere/include/stratosphere/tma/tma_i_file_accessor.hpp new file mode 100644 index 000000000..2cc088c60 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/tma/tma_i_file_accessor.hpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2018-2020 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 . + */ +#pragma once +#include +#include +#include + +/* NOTE: Minimum firmware version not enforced for any commands. */ +#define AMS_TMA_I_FILE_ACCESSOR_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, ReadFile, (ams::sf::Out out, s64 offset, const ams::sf::OutNonSecureBuffer &buffer, ams::fs::ReadOption option), (out, offset, buffer, option)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, WriteFile, (s64 offset, const ams::sf::InNonSecureBuffer &buffer, ams::fs::WriteOption option), (offset, buffer, option)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, GetFileSize, (ams::sf::Out out), (out)) \ + AMS_SF_METHOD_INFO(C, H, 3, Result, SetFileSize, (s64 size), (size)) \ + AMS_SF_METHOD_INFO(C, H, 4, Result, FlushFile, (), ()) \ + AMS_SF_METHOD_INFO(C, H, 5, Result, SetPriorityForFile, (s32 priority), (priority)) \ + AMS_SF_METHOD_INFO(C, H, 6, Result, GetPriorityForFile, (ams::sf::Out out), (out)) + +AMS_SF_DEFINE_INTERFACE(ams::tma, IFileAccessor, AMS_TMA_I_FILE_ACCESSOR_INTERFACE_INFO) diff --git a/libraries/libstratosphere/include/stratosphere/tma/tma_i_file_manager.hpp b/libraries/libstratosphere/include/stratosphere/tma/tma_i_file_manager.hpp new file mode 100644 index 000000000..43a7d77f3 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/tma/tma_i_file_manager.hpp @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018-2020 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 . + */ +#pragma once +#include +#include +#include +#include + +/* NOTE: Minimum firmware version not enforced for any commands. */ +#define AMS_TMA_I_FILE_MANAGER_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, OpenFile, (sf::Out> out, const tma::Path &path, bool case_sensitive), (out, path, case_sensitive)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, FileExists, (sf::Out out, const tma::Path &path, bool case_sensitive), (out, path, case_sensitive)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, DeleteFile, (const tma::Path &path, bool case_sensitive), (path, case_sensitive)) \ + AMS_SF_METHOD_INFO(C, H, 3, Result, RenameFile, (const tma::Path &old_path, const tma::Path &new_path, bool case_sensitive), (old_path, new_path, case_sensitive)) \ + AMS_SF_METHOD_INFO(C, H, 4, Result, GetIOType, (sf::Out out, const tma::Path &path, bool case_sensitive), (out, path, case_sensitive)) \ + AMS_SF_METHOD_INFO(C, H, 5, Result, OpenDirectory, (sf::Out> out, const tma::Path &path, bool case_sensitive), (out, path, case_sensitive)) \ + AMS_SF_METHOD_INFO(C, H, 6, Result, DirectoryExists, (sf::Out out, const tma::Path &path, bool case_sensitive), (out, path, case_sensitive)) \ + AMS_SF_METHOD_INFO(C, H, 7, Result, CreateDirectory, (const tma::Path &path, bool case_sensitive), (path, case_sensitive)) \ + AMS_SF_METHOD_INFO(C, H, 8, Result, DeleteDirectory, (const tma::Path &path, bool case_sensitive), (path, case_sensitive)) \ + AMS_SF_METHOD_INFO(C, H, 9, Result, RenameDirectory, (const tma::Path &old_path, const tma::Path &new_path, bool case_sensitive), (old_path, new_path, case_sensitive)) \ + AMS_SF_METHOD_INFO(C, H, 10, Result, CreateFile, (const tma::Path &path, s64 size, bool case_sensitive), (path, size, case_sensitive)) \ + AMS_SF_METHOD_INFO(C, H, 11, Result, GetFileTimeStamp, (sf::Out out_create, sf::Out out_access, sf::Out out_modify, const tma::Path &path, bool case_sensitive), (out_create, out_access, out_modify, path, case_sensitive)) \ + AMS_SF_METHOD_INFO(C, H, 12, Result, GetCaseSensitivePath, (const tma::Path &path, const sf::OutBuffer &out), (path, out)) \ + AMS_SF_METHOD_INFO(C, H, 13, Result, GetDiskFreeSpaceExW, (sf::Out out_free, sf::Out out_total, sf::Out out_total_free, const tma::Path &path), (out_free, out_total, out_total_free, path)) + +AMS_SF_DEFINE_INTERFACE(ams::tma, IFileManager, AMS_TMA_I_FILE_MANAGER_INTERFACE_INFO) diff --git a/libraries/libstratosphere/include/stratosphere/tma/tma_path.hpp b/libraries/libstratosphere/include/stratosphere/tma/tma_path.hpp new file mode 100644 index 000000000..f6d91db1f --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/tma/tma_path.hpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2018-2020 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 . + */ +#pragma once +#include +#include +#include +#include + +namespace ams::tma { + + struct Path : ams::sf::LargeData { + char str[fs::EntryNameLengthMax + 1]; + + static constexpr Path Encode(const char *p) { + Path path = {}; + for (size_t i = 0; i < sizeof(path) - 1; i++) { + path.str[i] = p[i]; + if (p[i] == '\x00') { + break; + } + } + return path; + } + + static constexpr size_t GetLength(const Path &path) { + size_t len = 0; + for (size_t i = 0; i < sizeof(path) - 1 && path.str[i] != '\x00'; i++) { + len++; + } + return len; + } + }; + + static_assert(util::is_pod::value && sizeof(Path) == fs::EntryNameLengthMax + 1); + +} \ No newline at end of file