2024-09-09 13:20:59 +08:00
|
|
|
#ifndef UTILTOOL_H
|
|
|
|
#define UTILTOOL_H
|
|
|
|
|
2024-06-18 13:25:20 +08:00
|
|
|
#include <array>
|
2024-10-08 14:37:53 +08:00
|
|
|
#include <string>
|
|
|
|
#include <string_view>
|
2024-06-18 13:25:20 +08:00
|
|
|
|
2024-09-09 13:20:59 +08:00
|
|
|
enum class MediaType{
|
|
|
|
VIDEO,
|
|
|
|
AUDIO,
|
|
|
|
IMAGE,
|
|
|
|
UNSUPPORT,
|
|
|
|
};
|
|
|
|
|
2024-06-18 13:25:20 +08:00
|
|
|
class UtilTool
|
|
|
|
{
|
2024-09-09 13:20:59 +08:00
|
|
|
private:
|
2024-10-08 14:37:53 +08:00
|
|
|
constexpr static std::array<std::string_view, 2> ImageTypes{"jpg","png"};
|
|
|
|
constexpr static std::array<std::string_view, 1> VideoTypes{"mp4"};
|
|
|
|
constexpr static std::array<std::string_view, 1> AudioTypes{"mp3"};
|
2024-06-18 13:25:20 +08:00
|
|
|
static bool CheckFileIsImage(const std::string& filename);
|
2024-09-09 13:20:59 +08:00
|
|
|
static bool CheckFileIsAudio(const std::string& filename);
|
|
|
|
static bool CheckFileIsVideo(const std::string& filename);
|
|
|
|
public:
|
|
|
|
static MediaType CheckFileType(const std::string& filename);
|
2024-06-18 13:25:20 +08:00
|
|
|
};
|
2024-09-09 13:20:59 +08:00
|
|
|
|
|
|
|
#endif // !UTILTOOL_H
|