#pragma once
#include <filesystem>
#include <string>
#include <vector>

#include "Deer/Tools/Path.h"

#define DEER_RESOURCE_PATH "Assets"

#define DEER_VOXEL_PATH "Voxels"
#define DEER_VOXEL_DATA_PATH "Voxels/Data"
#define DEER_VOXEL_ASPECT_PATH "Voxels/Visuals"
#define DEER_VOXEL_TEXTURE_PATH "Voxels/Textures"
#define DEER_VOXEL_SHADER_PATH "Voxels/Shaders"

#define DEER_EDITOR_PATH "Editor"
#define DEER_EDITOR_PANEL_PATH "Editor/Panels"
#define DEER_EDITOR_SERVICE_PATH "Editor/Services"

#define DEER_MESH_EXTENSION ".dmesh"
#define DEER_SHADER_EXTENSION ".glsl"
#define DEER_SCRIPT_EXTENSION ".as"

#define DEER_BIN_PATH "bin"
#define DEER_TEMP_PATH "tmp"
#define DEER_NULL_PATH "null"

namespace Deer {

	struct DirectoryData {
		std::vector<Path> dirs;
		std::vector<Path> elements;
	};

	// Namespace to manage memory interactions
	namespace DataStore {
		// Clears the cache of dir data
		void clearCache();

		// Rerturns a directory data with the elements relative to the id
		const DirectoryData& getDirData(const Path& id, const Path& dir, const char* extension);

		// TODO: Add safety
		// Returns the data of the specified file path
		bool loadFileData(const Path& id, const Path& name, uint8_t** data, uint32_t* size);
		// Returns the data of the specified file path avoiding extension
		bool loadGlobalFileData(const Path& id, const Path& name, uint8_t** data, uint32_t* size);
		void freeFileData(uint8_t*);

		void createFolder(const Path& path);

		void saveFile(const Path&, uint8_t* data, uint32_t size);
		uint8_t* readFile(const Path&, uint32_t* size);
		void deleteFile(const Path&);

		// Refactor----
		void compressFiles(std::vector<Path> files, const Path& path);
		std::vector<Path> getFiles(const Path& path,
		                           const std::string& extension);
		// Refactor----
	} // namespace DataStore
} // namespace Deer