#pragma once

// ::Packer::Includes::Header::

#if __linux__
# define _GNU_SOURCE
#elif _WIN32

#endif

#define STG_NO_RENDERER

#define STB_SPRINTF_IMPLEMENTATION

#define STB_IMAGE_IMPLEMENTATION

#include "stb/stb_sprintf.h"
#include "stb/stb_image.h"
#include "xxhash/xxhash.h"
#include "fastlz/fastlz.h"

#include "shared_types.h"
#include "assets.h"
#include "util.h"
#include "ds.h"
#include "platform/platform.h"
#include "allocators.h"
#include "renderer.h"
#include "game.h"

#include <stdio.h>

// ::Packer::Macros::Header::

#define FWrite(buf, size, count, file) ((size) * (fwrite(buf, size, count, file)))
#define FRead(buf, size, count, file) ((size) * (fread(buf, size, count, file)))

// ::Packer::Types::Header::

typedef struct FileMapping
{
	c8  *file_name;
	u32 ix;
} FileMapping;

// ::Packer::Files::Functions::Header::

FILE *pOpenFile(c8 *name, c8 *mode);
void CloseFile(FILE *file);
u64 FileLength(FILE *file);
u64 WriteData(void *buf, u64 pos, u64 size, FILE *file);
u64 ReadData(void *buf, u64 pos, u64 size, FILE *file);

// ::Packer::Packing::Functions::Header::

void SetArrayLookups();
void InitHeader(FileHeader *header);
i32 WriteHeader(FILE *file, FileHeader *header);
void PackFiles(Arena *arena, FileHeader *header);
void MoveToTextureDir(c8 **return_dir);
void MoveToShaderDir(c8 **return_dir);

// ::Packer::Tests::Functions::Header::

void TestAssetPack(Arena *arena);
static inline void TestAssetIsCorrect(Arena *arena, c8 *file_name, AssetFile *file_info, AssetType type, FILE *file);

// ::Packer::Main::Functions::Header::

int main(int argc, char **argv);
