Skip to content

Commit

Permalink
Refactor|FileSys: Further cleanup refactorings to the libdeng1 file s…
Browse files Browse the repository at this point in the history
…ystem
  • Loading branch information
danij-deng committed Oct 6, 2012
1 parent e71fd76 commit 42589c1
Show file tree
Hide file tree
Showing 15 changed files with 537 additions and 356 deletions.
338 changes: 207 additions & 131 deletions doomsday/engine/portable/include/fs_main.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/audiodriver_music.c
Expand Up @@ -62,7 +62,7 @@ static int musicPlayLump(audiointerface_music_t* iMusic, lumpnum_t lump, boolean
// Music interface does not offer buffer playback.
// Write this lump to disk and play from there.
AutoStr* musicFile = AudioDriver_Music_ComposeTempBufferFilename(0);
if(!F_DumpLump(lump, Str_Text(musicFile)))
if(!F_DumpLump2(lump, Str_Text(musicFile)))
{
// Failed to write the lump...
return 0;
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/src/dam_main.c
Expand Up @@ -109,7 +109,7 @@ static archivedmap_t* createArchivedMap(const Uri* uri, const ddstring_t* cached
Str_Init(&dam->cachedMapPath);
Str_Set(&dam->cachedMapPath, Str_Text(cachedMapPath));

if(DAM_MapIsValid(Str_Text(&dam->cachedMapPath), F_CheckLumpNumForName2(mapId, true)))
if(DAM_MapIsValid(Str_Text(&dam->cachedMapPath), F_LumpNumForName(mapId)))
dam->cachedMapFound = true;

return dam;
Expand Down Expand Up @@ -252,7 +252,7 @@ boolean DAM_AttemptMapLoad(const Uri* uri)
AutoStr* cachedMapDir;
Str cachedMapPath;

markerLump = F_CheckLumpNumForName2(mapId, true /*quiet please*/);
markerLump = F_LumpNumForName(mapId);
if(0 > markerLump) return false;

// Compose the cache directory path and ensure it exists.
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/src/dd_games.cpp
Expand Up @@ -163,7 +163,7 @@ boolean Games_IsNullObject(Game const* game)
/// @return @c true, iff the resource appears to be what we think it is.
static bool recognizeWAD(char const* filePath, void* parameters)
{
lumpnum_t auxLumpBase = F_OpenAuxiliary3(filePath, 0, true);
lumpnum_t auxLumpBase = F_OpenAuxiliary(filePath);
bool result = false;

if(auxLumpBase >= 0)
Expand All @@ -175,7 +175,7 @@ static bool recognizeWAD(char const* filePath, void* parameters)
result = true;
for(; result && *lumpNames; lumpNames++)
{
lumpnum_t lumpNum = F_CheckLumpNumForName2(Str_Text(*lumpNames), true);
lumpnum_t lumpNum = FS::lumpNumForName(Str_Text(*lumpNames));
if(lumpNum < 0)
{
result = false;
Expand Down
10 changes: 7 additions & 3 deletions doomsday/engine/portable/src/dd_main.c
Expand Up @@ -1189,10 +1189,14 @@ boolean DD_Init(void)
if(CommandLine_CheckWith("-dumplump", 1))
{
const char* name = CommandLine_Next();
lumpnum_t absoluteLumpNum = F_CheckLumpNumForName(name);
lumpnum_t absoluteLumpNum = F_LumpNumForName(name);
if(absoluteLumpNum >= 0)
{
F_DumpLump(absoluteLumpNum, NULL);
F_DumpLump(absoluteLumpNum);
}
else
{
Con_Message("Warning: Cannot dump unknown lump \"%s\", ignoring.\n", name);
}
}

Expand Down Expand Up @@ -2096,7 +2100,7 @@ D_CMD(Unload)
for(i = 1; i < argc; ++i)
{
if(!F_FindResource2(RC_PACKAGE, argv[i], &searchPath) ||
!F_RemoveFile(Str_Text(&searchPath), false/*not required game resources*/))
!F_RemoveFile2(Str_Text(&searchPath), false/*not required game resources*/))
{
continue;
}
Expand Down
18 changes: 9 additions & 9 deletions doomsday/engine/portable/src/dd_wad.cpp
Expand Up @@ -41,7 +41,7 @@ using de::AbstractFile;

size_t W_LumpLength(lumpnum_t absoluteLumpNum)
{
LumpInfo const* info = F_FindInfoForLumpNum(absoluteLumpNum);
LumpInfo const* info = FS::lumpInfo(absoluteLumpNum);
if(!info)
{
W_Error("W_LumpLength: Invalid lumpnum %i.", absoluteLumpNum);
Expand All @@ -63,7 +63,7 @@ char const* W_LumpName(lumpnum_t absoluteLumpNum)

uint W_LumpLastModified(lumpnum_t absoluteLumpNum)
{
LumpInfo const* info = F_FindInfoForLumpNum(absoluteLumpNum);
LumpInfo const* info = FS::lumpInfo(absoluteLumpNum);
if(!info)
{
W_Error("W_LumpLastModified: Invalid lumpnum %i.", absoluteLumpNum);
Expand All @@ -74,7 +74,7 @@ uint W_LumpLastModified(lumpnum_t absoluteLumpNum)

char const* W_LumpSourceFile(lumpnum_t absoluteLumpNum)
{
AbstractFile* file = FS::findFileForLumpNum(absoluteLumpNum);
AbstractFile* file = FS::lumpFile(absoluteLumpNum);
if(!file)
{
W_Error("W_LumpSourceFile: Invalid lumpnum %i.", absoluteLumpNum);
Expand All @@ -85,7 +85,7 @@ char const* W_LumpSourceFile(lumpnum_t absoluteLumpNum)

boolean W_LumpIsCustom(lumpnum_t absoluteLumpNum)
{
if(!F_IsValidLumpNum(absoluteLumpNum))
if(!FS::isValidLumpNum(absoluteLumpNum))
{
W_Error("W_LumpIsCustom: Invalid lumpnum %i.", absoluteLumpNum);
return false;
Expand All @@ -102,7 +102,7 @@ lumpnum_t W_CheckLumpNumForName2(char const* name, boolean silent)
VERBOSE2( Con_Message("Warning: W_CheckLumpNumForName: Empty name, returning invalid lumpnum.\n") )
return -1;
}
lumpNum = F_CheckLumpNumForName2(name, true);
lumpNum = FS::lumpNumForName(name);
if(!silent && lumpNum < 0)
VERBOSE2( Con_Message("Warning: W_CheckLumpNumForName: Lump \"%s\" not found.\n", name) )
return lumpNum;
Expand All @@ -126,7 +126,7 @@ lumpnum_t W_GetLumpNumForName(char const* name)
size_t W_ReadLump(lumpnum_t absoluteLumpNum, uint8_t* buffer)
{
int lumpIdx;
AbstractFile* file = FS::findFileForLumpNum(absoluteLumpNum, &lumpIdx);
AbstractFile* file = FS::lumpFile(absoluteLumpNum, &lumpIdx);
if(!file)
{
W_Error("W_ReadLump: Invalid lumpnum %i.", absoluteLumpNum);
Expand All @@ -138,7 +138,7 @@ size_t W_ReadLump(lumpnum_t absoluteLumpNum, uint8_t* buffer)
size_t W_ReadLumpSection(lumpnum_t absoluteLumpNum, uint8_t* buffer, size_t startOffset, size_t length)
{
int lumpIdx;
AbstractFile* file = FS::findFileForLumpNum(absoluteLumpNum, &lumpIdx);
AbstractFile* file = FS::lumpFile(absoluteLumpNum, &lumpIdx);
if(!file)
{
W_Error("W_ReadLumpSection: Invalid lumpnum %i.", absoluteLumpNum);
Expand All @@ -150,7 +150,7 @@ size_t W_ReadLumpSection(lumpnum_t absoluteLumpNum, uint8_t* buffer, size_t star
uint8_t const* W_CacheLump(lumpnum_t absoluteLumpNum)
{
int lumpIdx;
AbstractFile* file = FS::findFileForLumpNum(absoluteLumpNum, &lumpIdx);
AbstractFile* file = FS::lumpFile(absoluteLumpNum, &lumpIdx);
if(!file)
{
W_Error("W_CacheLump: Invalid lumpnum %i.", absoluteLumpNum);
Expand All @@ -162,7 +162,7 @@ uint8_t const* W_CacheLump(lumpnum_t absoluteLumpNum)
void W_UnlockLump(lumpnum_t absoluteLumpNum)
{
int lumpIdx;
AbstractFile* file = FS::findFileForLumpNum(absoluteLumpNum, &lumpIdx);
AbstractFile* file = FS::lumpFile(absoluteLumpNum, &lumpIdx);
if(!file)
{
W_Error("W_UnlockLump: Invalid lumpnum %i.", absoluteLumpNum);
Expand Down
20 changes: 16 additions & 4 deletions doomsday/engine/portable/src/def_main.c
Expand Up @@ -1266,7 +1266,7 @@ void Def_Read(void)

strcpy(si->id, snd->id);
strcpy(si->lumpName, snd->lumpName);
si->lumpNum = (strlen(snd->lumpName) > 0? F_CheckLumpNumForName2(snd->lumpName, true) : -1);
si->lumpNum = (strlen(snd->lumpName) > 0? F_LumpNumForName(snd->lumpName) : -1);
strcpy(si->name, snd->name);
k = Def_GetSoundNum(snd->link);
si->link = (k >= 0 ? sounds + k : 0);
Expand Down Expand Up @@ -1955,7 +1955,7 @@ int Def_Set(int type, int index, int value, const void* ptr)

if(sprite < 0 || sprite >= defs.count.sprites.num)
{
Con_Message("Def_Set: Warning, invalid sprite index %i.\n", sprite);
Con_Message("Warning: Def_Set: Unknown sprite index %i.\n", sprite);
break;
}

Expand All @@ -1972,14 +1972,26 @@ int Def_Set(int type, int index, int value, const void* ptr)

case DD_DEF_SOUND:
if(index < 0 || index >= countSounds.num)
Con_Error("Def_Set: Sound index %i is invalid.\n", index);
Con_Error("Warning: Def_Set: Sound index %i is invalid.\n", index);

switch(value)
{
case DD_LUMP:
S_StopSound(index, 0);
strcpy(sounds[index].lumpName, ptr);
sounds[index].lumpNum = F_CheckLumpNumForName(sounds[index].lumpName);
if(strlen(sounds[index].lumpName))
{
sounds[index].lumpNum = F_LumpNumForName(sounds[index].lumpName);
if(sounds[index].lumpNum < 0)
{
Con_Message("Warning: Def_Set: Unknown sound lump name \"%s\", sound (#%i) will be inaudible.\n",
sounds[index].lumpName, index);
}
}
else
{
sounds[index].lumpNum = 0;
}
break;

default:
Expand Down
10 changes: 5 additions & 5 deletions doomsday/engine/portable/src/def_read.c
Expand Up @@ -2738,14 +2738,14 @@ int DED_Read(ded_t* ded, const char* path)
int DED_ReadLump(ded_t* ded, lumpnum_t absoluteLumpNum)
{
int lumpIdx;
AbstractFile* fsObject = F_FindFileForLumpNum2(absoluteLumpNum, &lumpIdx);
if(fsObject)
AbstractFile* file = F_FindFileForLumpNum2(absoluteLumpNum, &lumpIdx);
if(file)
{
if(F_LumpLength(absoluteLumpNum) != 0)
{
const uint8_t* lumpPtr = F_CacheLump(fsObject, lumpIdx);
DED_ReadData(ded, (const char*)lumpPtr, Str_Text(AbstractFile_Path(fsObject)));
F_UnlockLump(fsObject, lumpIdx);
uint8_t const* lumpPtr = F_CacheLump(file, lumpIdx);
DED_ReadData(ded, (char const*)lumpPtr, Str_Text(AbstractFile_Path(file)));
F_UnlockLump(file, lumpIdx);
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/edit_map.c
Expand Up @@ -1723,7 +1723,7 @@ boolean MPE_End(void)
if(gamemap->uri && !Str_IsEmpty(Uri_Path(gamemap->uri)))
{
// Yes, write the cached map data file.
lumpnum_t markerLumpNum = F_CheckLumpNumForName2(Str_Text(Uri_Path(gamemap->uri)), true);
lumpnum_t markerLumpNum = F_LumpNumForName(Str_Text(Uri_Path(gamemap->uri)));
AutoStr* cachedMapDir = DAM_ComposeCacheDir(F_LumpSourceFile(markerLumpNum));
Str cachedMapPath;

Expand Down
8 changes: 4 additions & 4 deletions doomsday/engine/portable/src/finaleinterpreter.c
Expand Up @@ -1518,7 +1518,7 @@ DEFFC(Image)
{
fi_object_t* obj = getObject(fi, FI_PIC, OP_CSTRING(0));
const char* name = OP_CSTRING(1);
lumpnum_t lumpNum = F_CheckLumpNumForName2(name, true);
lumpnum_t lumpNum = F_LumpNumForName(name);
rawtex_t* rawTex;

FIData_PicClearAnimation(obj);
Expand All @@ -1538,7 +1538,7 @@ DEFFC(ImageAt)
float x = OP_FLOAT(1);
float y = OP_FLOAT(2);
const char* name = OP_CSTRING(3);
lumpnum_t lumpNum = F_CheckLumpNumForName2(name, true);
lumpnum_t lumpNum = F_LumpNumForName(name);
rawtex_t* rawTex;

AnimatorVector3_Init(obj->pos, x, y, 0);
Expand Down Expand Up @@ -1658,7 +1658,7 @@ DEFFC(AnimImage)
fi_object_t* obj = getObject(fi, FI_PIC, OP_CSTRING(0));
const char* name = OP_CSTRING(1);
int tics = FRACSECS_TO_TICKS(OP_FLOAT(2));
lumpnum_t lumpNum = F_CheckLumpNumForName2(name, true);
lumpnum_t lumpNum = F_LumpNumForName(name);
rawtex_t* rawTex = R_GetRawTex(lumpNum);
if(NULL != rawTex)
{
Expand Down Expand Up @@ -2013,7 +2013,7 @@ DEFFC(TextFromLump)

AnimatorVector3_Init(obj->pos, OP_FLOAT(1), OP_FLOAT(2), 0);

absoluteLumpNum = F_CheckLumpNumForName2(OP_CSTRING(3), true);
absoluteLumpNum = F_LumpNumForName(OP_CSTRING(3));
if(absoluteLumpNum >= 0)
{
int lumpIdx;
Expand Down

0 comments on commit 42589c1

Please sign in to comment.