|
|
1.1 ! root 1: // ! 2: // nono ! 3: // Copyright (C) 2023 nono project ! 4: // Licensed under nono-license.txt ! 5: // ! 6: ! 7: // ! 8: // Windrv (相当) ホストドライバ ! 9: // ! 10: ! 11: #pragma once ! 12: ! 13: #include "windrv.h" ! 14: #include <map> ! 15: #include <vector> ! 16: ! 17: // Windrv のホスト実装。 ! 18: class HostWindrv : public Device ! 19: { ! 20: using inherited = Device; ! 21: ! 22: // dirs の最大ディレクトリ数。 ! 23: static const int MaxVDirs = 20; ! 24: ! 25: public: ! 26: HostWindrv(WindrvDevice *parent_); ! 27: ~HostWindrv() override; ! 28: ! 29: // ルートパスの設定。 ! 30: void InitRootPath(const std::string& rootpath_); ! 31: ! 32: uint32 Initialize(); ! 33: ! 34: uint32 GetCapacity(Human68k::capacity *); ! 35: ! 36: // ゲストパスのディレクトリをオープンする。 ! 37: VDir *OpenVDir(const std::string& path_); ! 38: // vdir をクローズする。 ! 39: void CloseVDir(VDir *); ! 40: ! 41: // path のファイルエントリについて FILES の以下を埋めて返す。 ! 42: // .attr Human68k のファイル属性 ! 43: // .date Human68k 形式の日付 ! 44: // .time Human68k 形式の時刻 ! 45: // .size ファイルサイズ ! 46: bool GetFileStat(Human68k::FILES *dst, const std::string& path) const; ! 47: ! 48: uint32 MakeDir(const std::string& path_); ! 49: uint32 RemoveDir(const std::string& path_); ! 50: uint32 Rename(const std::string& oldpath, const std::string& newpath); ! 51: uint32 Delete(const std::string& path_); ! 52: uint32 GetAttribute(const std::string& path_); ! 53: uint32 SetAttribute(const std::string& path_, uint8 attr_); ! 54: uint32 CreateFile(Windrv::FCB *, const std::string& path_, uint8 attr); ! 55: uint32 Open(Windrv::FCB *, const std::string& path_); ! 56: void Close(Windrv::FCB *); ! 57: uint32 Read(Windrv::FCB *, void *dst, uint32 len); ! 58: uint32 Write(Windrv::FCB *, const void *src, uint32 len); ! 59: uint32 Seek(Windrv::FCB *, int whence, int32 offset); ! 60: uint32 GetFileTime(Windrv::FCB *); ! 61: uint32 SetFileTime(Windrv::FCB *, uint32 datetime); ! 62: uint32 Flush(); ! 63: ! 64: private: ! 65: // 仮想ディレクトリ構造 ! 66: ! 67: // ゲストパス path に対応する VDir を (必要なら作成して) 返す。 ! 68: // 見付からなければ NULL を返す。 ! 69: VDir *GetVDirByGuest(const std::string& path); ! 70: ! 71: // ホスト相対パス path に対応する VDir があれば返す。 ! 72: // 見付からなければ NULL を返す。 ! 73: VDir *FindVDir(const std::string& path) const; ! 74: ! 75: // vdir を必要なら更新。 ! 76: bool UpdateVDir(VDir *vdir); ! 77: ! 78: // ホスト相対パス path に対応する VDir を作成して追加。 ! 79: VDir *AddVDir(const std::string& path); ! 80: ! 81: // vdir のディレクトリエントリを(再)構成する。 ! 82: bool FillVDir(VDir *, const char *caller, bool force); ! 83: ! 84: // path を分離する。 ! 85: static std::vector<std::string> SplitPath(const std::string& path); ! 86: ! 87: // path を正規化する。 ! 88: static std::string NormalizePath(const std::string& path); ! 89: ! 90: // name が Human68k ファイル名の制約を満たしていれば true を返す。 ! 91: bool IsHuman68kFilename(const char *name) const; ! 92: ! 93: // ホストパス path の属性を返す。 ! 94: uint32 GetAttributeInternal(const std::string& path, struct stat *) const; ! 95: ! 96: #if defined(HAVE_STAT_ST_TIMESPEC) ! 97: static uint64 timespec2nsec(const struct timespec& ts); ! 98: #endif ! 99: ! 100: // 文字コード(未対応) ! 101: std::string ToHostCharset(const std::string& src) const; ! 102: std::string ToGuestCharset(const std::string& src) const; ! 103: ! 104: // ルートディレクトリのホスト側パス。末尾 '/'。 ! 105: std::string rootpath {}; ! 106: ! 107: // ホスト相対パスと対応する仮想ディレクトリの連想配列。 ! 108: std::map<std::string, VDir *> vdirs {}; ! 109: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.