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

#ifndef __KMFILEINFO_H__
#define __KMFILEINFO_H__

#include <string>
#include <memory>
#include <gio/gio.h>

/**
 * KMFileInfo:
 * @brief : 对gio的GFileInfo的简单封装
 * @note  : 只封装了使用到的接口
 */
class KMFileInfo
{
public:
    KMFileInfo(bool empty = false);
    KMFileInfo(const std::string &filename);
    KMFileInfo(GFileInfo *fileinfo);
    KMFileInfo(const KMFileInfo &other);
    KMFileInfo(KMFileInfo &&other);
    ~KMFileInfo();

    KMFileInfo &operator=(const KMFileInfo &other);
    KMFileInfo &operator=(KMFileInfo &&other);
    KMFileInfo &operator=(GFileInfo *fileinfo);

    void setName(const std::string &filename);
    std::string getName() const;

    void setFileType(GFileType type);
    GFileType getFileType() const;

    void setAttribute(const std::string &attribute, std::uint32_t attrValue);

    operator bool() const;

    GFileInfo *get();

    std::uint64_t getSize() const;

private:
    void setValid(bool valid);

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

#endif // !__KMFILEINFO_H__
