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)
|
|
|
|
{
|
2021-11-21 17:16:14 +00:00
|
|
|
cmdline_fix(&argc, &argv);
|
2021-12-21 16:19:42 +00:00
|
|
|
IStorage *pStorage = CreateStorage(IStorage::STORAGETYPE_BASIC, argc, argv);
|
2011-02-12 10:40:36 +00:00
|
|
|
int Index, ID = 0, Type = 0, Size;
|
2010-05-29 07:25:38 +00:00
|
|
|
void *pPtr;
|
2021-09-13 08:06:34 +00:00
|
|
|
char aFileName[IO_MAX_PATH_LENGTH];
|
2010-05-29 07:25:38 +00:00
|
|
|
CDataFileReader DataFile;
|
|
|
|
CDataFileWriter df;
|
|
|
|
|
2010-08-05 18:34:16 +00:00
|
|
|
if(!pStorage || argc != 3)
|
2010-05-29 07:25:38 +00:00
|
|
|
return -1;
|
|
|
|
|
2012-01-09 00:38:45 +00:00
|
|
|
str_format(aFileName, sizeof(aFileName), "%s", argv[2]);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2017-07-12 18:15:00 +00:00
|
|
|
if(!DataFile.Open(pStorage, argv[1], IStorage::TYPE_ABSOLUTE))
|
2010-05-29 07:25:38 +00:00
|
|
|
return -1;
|
|
|
|
if(!df.Open(pStorage, aFileName))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
// add all items
|
|
|
|
for(Index = 0; Index < DataFile.NumItems(); Index++)
|
2011-04-13 18:37:12 +00:00
|
|
|
{
|
2011-02-12 10:40:36 +00:00
|
|
|
pPtr = DataFile.GetItem(Index, &Type, &ID);
|
2010-05-29 07:25:38 +00:00
|
|
|
Size = DataFile.GetItemSize(Index);
|
2021-05-03 08:43:00 +00:00
|
|
|
|
|
|
|
// filter ITEMTYPE_EX items, they will be automatically added again
|
|
|
|
if(Type == ITEMTYPE_EX)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-02-12 10:40:36 +00:00
|
|
|
df.AddItem(Type, ID, Size, pPtr);
|
2010-05-29 07:25:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// add all data
|
|
|
|
for(Index = 0; Index < DataFile.NumData(); Index++)
|
|
|
|
{
|
|
|
|
pPtr = DataFile.GetData(Index);
|
2017-08-30 06:36:17 +00:00
|
|
|
Size = DataFile.GetDataSize(Index);
|
2010-05-29 07:25:38 +00:00
|
|
|
df.AddData(Size, pPtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
DataFile.Close();
|
|
|
|
df.Finish();
|
2021-11-21 17:16:14 +00:00
|
|
|
cmdline_free(argc, argv);
|
2010-05-29 07:25:38 +00:00
|
|
|
return 0;
|
|
|
|
}
|