Annotation of nono/host/diskimage.h, revision 1.1.1.1

1.1       root        1: //
                      2: // nono
                      3: // Copyright (C) 2021 nono project
                      4: // Licensed under nono-license.txt
                      5: //
                      6: 
                      7: #pragma once
                      8: 
                      9: #include "header.h"
                     10: 
                     11: // ディスクイメージの基本クラス
                     12: class DiskImage
                     13: {
                     14:  public:
                     15:        enum class Type {
                     16:                Raw,            // 生イメージ
                     17:        };
                     18: 
                     19:  public:
                     20:        DiskImage(Type type_);
                     21:        virtual ~DiskImage();
                     22: 
                     23:        static DiskImage *Create(const std::string& pathname);
                     24: 
                     25:        // このディスクイメージのサイズと書き込み可能かどうかを返す。
                     26:        // Open() 前でも動作する。
                     27:        // 成功すれば 0、失敗なら errno をセットして - 1を返す。
                     28:        virtual int GetInfo(off_t *size, bool *w_ok) = 0;
                     29: 
                     30:        // このディスクイメージを実際のアクセス用にオープンする。
                     31:        // 失敗すれば warn() でエラーメッセージを表示して false を返す。
                     32:        virtual bool Open(bool read_only) = 0;
                     33: 
                     34:        // このディスクイメージの offset から size バイトを buf に読み出す
                     35:        virtual bool Read(void *buf, off_t offset, size_t size) = 0;
                     36: 
                     37:        // このディスクイメージの offset から size バイトに buf を書き込む
                     38:        virtual bool Write(const void *buf, off_t offset, size_t size) = 0;
                     39: 
                     40:        // このディスクイメージをクローズする
                     41:        virtual void Close() = 0;
                     42: 
                     43:        // このディスクイメージのバイト数を返す。
                     44:        // オープン後のみ使用可能。
                     45:        virtual off_t GetSize() const = 0;
                     46: 
                     47:        // このディスクイメージの種別を返す
                     48:        Type GetDiskImageType() const { return type; }
                     49: 
                     50:        // このディスクイメージのパス込みのファイル名を返す
                     51:        const std::string& GetPathName() const { return pathname; }
                     52: 
                     53:  protected:
                     54:        Type type {};
                     55: 
                     56:        std::string pathname {};
                     57: };

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.