#pragma once
#include <string>
#include "zstd/table.h"
#include "UTemplate/Type.hpp"
namespace engineapi
{
	using std::string;
	using std::string_view;
	using zstd::table;
	using zstd::hash_table;
	using Ubpa::Name;
	using Ubpa::NameID;
	enum FileFlag : uint32_t {
		File_Default    = 0,
		File_Success    = 1 << 0,
		File_Binary		= 1 << 1,
		File_Compress	= 1 << 2,
		File_Http		= 1 << 3,
		File_Not_Exist  = 1 << 4,
		File_Error      = 1 << 5,
	};
	struct PackagePath {
		string_view path;
		PackagePath() {};
		PackagePath(const char* path) : path(path) {}
		PackagePath(const string_view& path) : path(path) {}
		PackagePath(const string& path) : path(path) {}
		PackagePath(const string&& path) : path(path) {}
		size_t size() const{
			return path.size();
		}
		string operator+(const char* suffix) const {
			return string(path) + suffix;
		}
		string_view ParsePackage()const {
			string_view name;
            if (path[0] == '/') {
				size_t pos = path.find('/', 1);
				if (pos != string::npos) {
					return path.substr(1, pos - 1);
				}
            }
			return name;
		}
		string_view GetFileName()const {
			size_t pos = path.rfind('/');
			if (pos != std::string::npos)
				return path.substr(pos + 1);
			return "";
		}
		Name GetExtension() const{
			size_t pos = path.rfind('.');
			if (pos != std::string::npos)
				return path.substr(pos);
			return "";
		}
		PackagePath ToSuffixPath(const string_view& suffix)const;
		PackagePath SafePath()const;
		string RealPath()const;
	};
}