Skip to content

Commit

Permalink
F API: M_ReadFileIntoString() supports paths like "LumpIndex:<lumpnum…
Browse files Browse the repository at this point in the history
…ber>"

The file to read can now be specified with a URI like reference into
the engine's central LumpIndex.
  • Loading branch information
danij-deng committed Sep 9, 2014
1 parent 0fa6a5c commit 2c79f4c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions doomsday/client/src/m_misc.cpp
Expand Up @@ -247,6 +247,32 @@ DENG_EXTERN_C AutoStr *M_ReadFileIntoString(ddstring_t const *path, dd_bool *isC
{
if(isCustom) *isCustom = false;

if(Str_StartsWith(path, "LumpIndex:"))
{
bool isNumber;
lumpnum_t const lumpNum = String(Str_Text(path) + 10).toInt(&isNumber);
LumpIndex const &lumpIndex = App_FileSystem().nameIndex();
if(isNumber && lumpIndex.hasLump(lumpNum))
{
File1 &lump = lumpIndex.lump(lumpNum);
if(isCustom) *isCustom = lump.hasCustom();

// Ignore zero-length lumps.
if(!lump.size()) return 0;

// Ensure the resulting string is terminated.
AutoStr *string = Str_PartAppend(AutoStr_NewStd(), (char const *)lump.cache(), 0, lump.size());
lump.unlock();

if(Str_IsEmpty(string))
return 0;

return string;
}

return 0;
}

if(Str_StartsWith(path, "Lumps:"))
{
char const *lumpName = Str_Text(path) + 6;
Expand Down

0 comments on commit 2c79f4c

Please sign in to comment.