/* common/KMOstreeRepoFile.h
 *
 * Copyright (C) 2023 OpenKylin, Inc
 */

#ifndef __KMOSTREEREPOFILE_H__
#define __KMOSTREEREPOFILE_H__


#include <gio/gio.h>
#include <ostree.h>

#include <memory>
#include <string>

#include "KMFile.h"

/**
 * @brief : 对OstreeRepoFile的简单封装
 * @note  : ostree_repo_file_开头的函数都可以迁移进来
 */
class KMOstreeRepoFile
{
public:
    KMOstreeRepoFile();
    KMOstreeRepoFile(const KMOstreeRepoFile &other);
    KMOstreeRepoFile(KMOstreeRepoFile &&other);
    KMOstreeRepoFile(KMFile &file);
    KMOstreeRepoFile(GFile *file, bool needFree = true);
    KMOstreeRepoFile(OstreeRepoFile *file, bool needFree = true);
    ~KMOstreeRepoFile();

    KMOstreeRepoFile &operator=(const KMOstreeRepoFile &other);
    KMOstreeRepoFile &operator=(KMOstreeRepoFile &&other);

    // KMOstreeRepoFile& operator=(OstreeRepoFile* file);
    // KMOstreeRepoFile& operator=(GFile* file);
    // void setNeedFree(bool needFree);

    operator bool() const { return d.operator bool(); }

    OstreeRepoFile *get();

    const char *getChecksum();

public:
private:
    class Private;
    std::shared_ptr<Private> d = nullptr;
};

#endif // !__KMOSTREEREPOFILE_H__
