void PackageFile::AddDirectory(XDirectory* directory)
{
    PointerList<XFile*>* files = directory->GetFiles(true);

    auto it = files->GetContainer()->begin();
    while (it != files->GetContainer()->end())
    {
        XFile* file = *it;

        this->AddFile(file->FilePath, directory->FullPath);

        it++;
    }

    files->Release();
    delete(files);
}
PointerList<BaseSprite*>* Spritesheet::ExtractSprites()
{
    assert(this->ConfigFilePath != "");
    assert(this->SpritesheetFilePath != "");
    assert(this->Graphics != NULL);

    PointerList<BaseSprite*>* spriteList = new PointerList<BaseSprite*>();

    XmlReader configReader = XmlReader();
    configReader.LoadFile(this->ConfigFilePath);
    PointerList<XmlNode*>* nodes = configReader.FindNodes("sprite");

    auto it = nodes->GetContainer()->begin();
    while (it != nodes->GetContainer()->end())
    {
        XmlNode* node = (*it);

        std::string spriteName = node->GetAttribute("n").AttributeValue;
        int spriteSubTextureX = std::atoi(node->GetAttribute("x").AttributeValue);
        int spriteSubTextureY = std::atoi(node->GetAttribute("y").AttributeValue);
        int spriteSubTextureW = std::atoi(node->GetAttribute("w").AttributeValue);
        int spriteSubTextureH = std::atoi(node->GetAttribute("h").AttributeValue);

        FRectangle subRec = FRectangle(spriteSubTextureX, spriteSubTextureY, spriteSubTextureW, spriteSubTextureH);

        BaseSprite* newSprite = Graphics->CreateSpriteInstance();
        newSprite->Ident = spriteName;

        BaseTexture* newSpriteTexture = spritesheetTexture->GetSubTexture(subRec);
        newSprite->SetTexture(newSpriteTexture);
        newSpriteTexture->TextureName = spriteName;
        newSpriteTexture->TexturePath = this->SpritesheetFilePath;

        spriteList->Add(newSprite);

        it++;
    }

    nodes->Release();
    delete(nodes);

    return spriteList;
}