MGL(Win32)
読み取り中…
検索中…
一致する文字列を見つけられません
mgl_file_delegate_win32.h
[詳解]
1// SPDX-License-Identifier: Zlib
2/* ------------------------------------------------------------------------- */
9/* ------------------------------------------------------------------------- */
10
11#ifndef INCGUARD_MGL_FILE_DELEGATE_WIN32_H_1616786750
12#define INCGUARD_MGL_FILE_DELEGATE_WIN32_H_1616786750
13
14#include <mgl/mgl_environment.h>
15#if defined(MGL_FILE_DELEGATE_ENABLE_WIN32)
16
19
20namespace MGL::File
21{
23class Win32Delegate : public Delegate
24{
25public:
27 static constexpr DelegateKey kDelegateKey = MakeDelegateKey("MGL-Win32");
28
29 /* ------------------------------------------------------------------------- */
35 /* ------------------------------------------------------------------------- */
36 [[nodiscard]] bool IsManagedSystemNativeFile() const noexcept override
37 {
38 return true;
39 }
40
41 /* ------------------------------------------------------------------------- */
47 /* ------------------------------------------------------------------------- */
48 [[nodiscard]] bool IsWritable() const noexcept override
49 {
50 return true; // 対応している
51 }
52
53 /* ------------------------------------------------------------------------- */
61 /* ------------------------------------------------------------------------- */
62 Result Mount([[maybe_unused]] SharedMountWork &mountWork, [[maybe_unused]] const PathView &path, [[maybe_unused]] MountAccessType accessType) noexcept override
63 {
64 return Result::Succeeded(); // このデリゲートはマウントワークを使用しないので何もせずに成功を返す
65 }
66
67 /* ------------------------------------------------------------------------- */
72 /* ------------------------------------------------------------------------- */
73 void Unmount([[maybe_unused]] SharedMountWork &mountWork) noexcept override
74 {
75 }
76
77 AccessWorkPtr Open(Result &result, SharedMountWork &mountWork, const PathView &path, OpenMode mode) noexcept override;
78 Result Close(AccessWork *work) noexcept override;
79
80 size_t Read(AccessWork *work, Result &result, void *buffer, size_t size) noexcept override;
81 size_t Write(AccessWork *work, Result &result, const void *buffer, size_t size) noexcept override;
82 size_t Seek(AccessWork *work, Result &result, SeekType seekType, int32_t offset) noexcept override;
83 size_t GetOffset(AccessWork *work, Result &result) const noexcept override;
84 bool IsEOF(AccessWork *work, Result &result) const noexcept override;
85 size_t GetSize(AccessWork *work, Result &result) const noexcept override;
86
87 size_t GetSize(MountWork *mountWork, Result &result, const PathView &path) const noexcept override;
88 Result MakeDirectory(MountWork *mountWork, const PathView &path) noexcept override;
89 Result Move(MountWork *mountWork, const PathView &sourcePath, const PathView &destPath) noexcept override;
90 Result Remove(MountWork *mountWork, const PathView &path) noexcept override;
91 bool Exists(MountWork *mountWork, Result &result, const PathView &path) noexcept override;
92
94 struct Win32Work : public AccessWork
95 {
96 FILE *fp{nullptr};
97 size_t size{0};
98
100 Win32Work(OpenMode mode) noexcept
101 : AccessWork(mode, kDelegateKey)
102 {}
103 };
104
105private:
106 [[nodiscard]] static Win32Work *GetWork(AccessWork *work, OpenMode mode = OpenMode::None) noexcept;
107 [[nodiscard]] static const wchar_t *GetModeString(OpenMode mode) noexcept;
108 [[nodiscard]] static STL::wstring ConvertPath(const PathView &path) noexcept;
109 [[nodiscard]] static Error GetError(int errorNumber) noexcept;
110};
111} // namespace MGL::File
112
113#endif // MGL_FILE_DELEGATE_ENABLE_WIN32
114#endif // INCGUARD_MGL_FILE_DELEGATE_WIN32_H_1616786750
115
116// vim: et ts=4 sw=4 sts=4
ファイルアクセスのための作業用クラス
Definition mgl_file_access_work.h:24
AccessWork(OpenMode mode, DelegateKey key) noexcept
コンストラクタ
Definition mgl_file_access_work.cc:24
ファイルデリゲートクラス
Definition mgl_file_delegate.h:25
マウント毎のワークの基底クラス
Definition mgl_file_mount_work.h:20
文字列の参照のみを行うファイルパスクラス
Definition mgl_file_path_view.h:20
Win32用ファイルデリゲートクラス
Definition mgl_file_delegate_win32.h:24
static constexpr DelegateKey kDelegateKey
このデリゲートを表すデリゲートキー
Definition mgl_file_delegate_win32.h:27
Result MakeDirectory(MountWork *mountWork, const PathView &path) noexcept override
ディレクトリを作成する
Definition mgl_file_delegate_win32.cc:328
bool Exists(MountWork *mountWork, Result &result, const PathView &path) noexcept override
ファイルの存在をチェック
Definition mgl_file_delegate_win32.cc:399
void Unmount(SharedMountWork &mountWork) noexcept override
マウント解除時の処理
Definition mgl_file_delegate_win32.h:73
size_t GetSize(AccessWork *work, Result &result) const noexcept override
オープンしているファイルのサイズを取得
Definition mgl_file_delegate_win32.cc:263
Result Close(AccessWork *work) noexcept override
ファイルをクローズ
Definition mgl_file_delegate_win32.cc:61
size_t GetOffset(AccessWork *work, Result &result) const noexcept override
ストリーム位置を取得
Definition mgl_file_delegate_win32.cc:202
Result Mount(SharedMountWork &mountWork, const PathView &path, MountAccessType accessType) noexcept override
マウント時の処理
Definition mgl_file_delegate_win32.h:62
Result Remove(MountWork *mountWork, const PathView &path) noexcept override
ファイルの削除
Definition mgl_file_delegate_win32.cc:378
bool IsManagedSystemNativeFile() const noexcept override
このデリゲートがシステム標準のファイルを扱うものかを取得
Definition mgl_file_delegate_win32.h:36
bool IsEOF(AccessWork *work, Result &result) const noexcept override
ファイルストリームが終端に達しているかを取得
Definition mgl_file_delegate_win32.cc:232
AccessWorkPtr Open(Result &result, SharedMountWork &mountWork, const PathView &path, OpenMode mode) noexcept override
ファイルをオープン
Definition mgl_file_delegate_win32.cc:29
Result Move(MountWork *mountWork, const PathView &sourcePath, const PathView &destPath) noexcept override
ファイルの移動・リネーム
Definition mgl_file_delegate_win32.cc:358
bool IsWritable() const noexcept override
このデリゲートが書き込みに対応しているかを取得
Definition mgl_file_delegate_win32.h:48
size_t Seek(AccessWork *work, Result &result, SeekType seekType, int32_t offset) noexcept override
ストリーム位置を設定
Definition mgl_file_delegate_win32.cc:156
static constexpr ResultWrapper Succeeded() noexcept
Definition mgl_result_wrapper.h:101
MGL 環境定義
STL::unique_ptr< AccessWork > AccessWorkPtr
ファイルアクセスのためのワークのポインタ型
Definition mgl_file_access_work.h:130
MountAccessType
マウント時のアクセスタイプ
Definition mgl_file_defs.h:56
DelegateKey
デリゲートキーの型
Definition mgl_file_defs.h:23
SeekType
シークタイプ
Definition mgl_file_defs.h:63
Error
エラー定義
Definition mgl_file_defs.h:71
constexpr DelegateKey MakeDelegateKey(const char *keyString, uint32_t seed=kDefaultDelegateKeySeed) noexcept
デリゲートキーの生成
Definition mgl_file_defs.h:36
OpenMode
オープンモード
Definition mgl_file_defs.h:48
MGL ファイルデリゲート
std::shared_ptr< MountWork > SharedMountWork
マウント毎のワークの共有ポインタ
Definition mgl_file_mount_work.h:51
MGL STL文字列クラスの代替
basic_string< wchar_t > wstring
std::wstringの代替
Definition mgl_stl_string.h:34
このデリゲート用の作業用構造体
Definition mgl_file_delegate_win32.h:95
size_t size
ファイルサイズ
Definition mgl_file_delegate_win32.h:97
Win32Work(OpenMode mode) noexcept
初期化用コンストラクタ
Definition mgl_file_delegate_win32.h:100
FILE * fp
ファイルポインタ
Definition mgl_file_delegate_win32.h:96