-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFileSystem.h
More file actions
34 lines (31 loc) · 1.63 KB
/
Copy pathFileSystem.h
File metadata and controls
34 lines (31 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#pragma once
#include "Export.h"
#include "ISerializable.h"
#include <string>
#include <filesystem>
#include <optional>
namespace sh::core
{
class FileSystem
{
public:
SH_CORE_API static auto GetDesktopDirectory() -> std::string;
SH_CORE_API static auto GetHomeDirectory() -> std::string;
SH_CORE_API static auto GetExecutableDirectory() -> std::filesystem::path;
/// @brief 해당 경로에 폴더를 만드는 함수. 이미 존재한다면 뒤에 숫자를 붙인다.
/// @param path 경로
/// @param name 폴더 이름
SH_CORE_API static void CreateFolder(const std::filesystem::path& path, std::string_view folderName);
/// @brief 해당 경로에 같은 이름의 파일이 존재 할 시 이름에 숫자를 붙여 반환하는 함수
/// @param path 경로
/// @param fileName 파일 이름
/// @return 새 파일 이름
SH_CORE_API static auto CreateUniqueFileName(const std::filesystem::path& path, const std::filesystem::path& fileName) -> std::string;
SH_CORE_API static void CopyAllFiles(const std::filesystem::path& source, const std::filesystem::path& target);
SH_CORE_API static auto LoadBinary(const std::filesystem::path& path) -> std::optional<std::vector<unsigned char>>;
SH_CORE_API static auto SaveBinary(const std::vector<uint8_t>& binary, const std::filesystem::path& path) -> bool;
SH_CORE_API static auto LoadText(const std::filesystem::path& path) -> std::optional<std::string>;
SH_CORE_API static auto SaveText(const std::string& text, const std::filesystem::path& path) -> bool;
SH_CORE_API static auto SaveText(const core::Json& json, const std::filesystem::path& path) -> bool;
};
}//namespace