2010-11-20 10:37:14 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <base/system.h>
|
|
|
|
#include <engine/shared/datafile.h>
|
|
|
|
#include <engine/storage.h>
|
|
|
|
|
|
|
|
int main(int argc, const char **argv)
|
|
|
|
{
|
2022-06-05 14:43:00 +00:00
|
|
|
tw::CCmdlineFix CmdlineFix(&argc, &argv);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2022-05-31 20:46:20 +00:00
|
|
|
IStorage *pStorage = CreateStorage(IStorage::STORAGETYPE_BASIC, argc, argv);
|
2010-08-05 18:34:16 +00:00
|
|
|
if(!pStorage || argc != 3)
|
2010-05-29 07:25:38 +00:00
|
|
|
return -1;
|
|
|
|
|
2022-05-31 20:46:20 +00:00
|
|
|
CDataFileReader Reader;
|
|
|
|
if(!Reader.Open(pStorage, argv[1], IStorage::TYPE_ABSOLUTE))
|
2010-05-29 07:25:38 +00:00
|
|
|
return -1;
|
2022-05-31 20:46:20 +00:00
|
|
|
|
|
|
|
CDataFileWriter Writer;
|
|
|
|
if(!Writer.Open(pStorage, argv[2]))
|
2010-05-29 07:25:38 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
// add all items
|
2022-05-31 20:46:20 +00:00
|
|
|
for(int Index = 0; Index < Reader.NumItems(); Index++)
|
2011-04-13 18:37:12 +00:00
|
|
|
{
|
2022-05-31 20:46:20 +00:00
|
|
|
int Type, ID;
|
|
|
|
void *pPtr = Reader.GetItem(Index, &Type, &ID);
|
2021-05-03 08:43:00 +00:00
|
|
|
|
|
|
|
// filter ITEMTYPE_EX items, they will be automatically added again
|
|
|
|
if(Type == ITEMTYPE_EX)
|
|
|
|
continue;
|
|
|
|
|
2022-05-31 20:46:20 +00:00
|
|
|
int Size = Reader.GetItemSize(Index);
|
|
|
|
Writer.AddItem(Type, ID, Size, pPtr);
|
2010-05-29 07:25:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// add all data
|
2022-05-31 20:46:20 +00:00
|
|
|
for(int Index = 0; Index < Reader.NumData(); Index++)
|
2010-05-29 07:25:38 +00:00
|
|
|
{
|
2022-05-31 20:46:20 +00:00
|
|
|
void *pPtr = Reader.GetData(Index);
|
|
|
|
int Size = Reader.GetDataSize(Index);
|
|
|
|
Writer.AddData(Size, pPtr);
|
2010-05-29 07:25:38 +00:00
|
|
|
}
|
|
|
|
|
2022-05-31 20:46:20 +00:00
|
|
|
Reader.Close();
|
|
|
|
Writer.Finish();
|
2010-05-29 07:25:38 +00:00
|
|
|
return 0;
|
|
|
|
}
|