Skip to content

Commit

Permalink
Cleanup: Removed obsolete FS1 file_s/filehandle_s, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Jun 17, 2014
1 parent 72a64c9 commit fdc8566
Show file tree
Hide file tree
Showing 24 changed files with 178 additions and 258 deletions.
4 changes: 2 additions & 2 deletions doomsday/client/src/audio/s_cache.cpp
Expand Up @@ -584,7 +584,7 @@ static sfxsample_t *cacheSample(int id, sfxinfo_t const *info)
if(lumpLength <= 8) return 0;

int lumpIdx;
de::File1 *file = F_FindFileForLumpNum(info->lumpNum, &lumpIdx);
File1 *file = F_FindFileForLumpNum(info->lumpNum, &lumpIdx);
DENG2_ASSERT(file != 0);

char hdr[12];
Expand Down Expand Up @@ -629,7 +629,7 @@ static sfxsample_t *cacheSample(int id, sfxinfo_t const *info)
if(lumpLength > 8)
{
int lumpIdx;
de::File1 *file = F_FindFileForLumpNum(info->lumpNum, &lumpIdx);
File1 *file = F_FindFileForLumpNum(info->lumpNum, &lumpIdx);
DENG2_ASSERT(file != 0);

uint8_t hdr[8];
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/audio/s_mus.cpp
Expand Up @@ -210,7 +210,7 @@ dd_bool Mus_IsMUSLump(lumpnum_t lumpNum)
{
char buf[4];
int lumpIdx;
de::File1 *file = F_FindFileForLumpNum(lumpNum, &lumpIdx);
File1 *file = F_FindFileForLumpNum(lumpNum, &lumpIdx);
if(!file) return false;

F_ReadLumpSection(file, lumpIdx, (uint8_t *)buf, 0, 4);
Expand Down Expand Up @@ -312,7 +312,7 @@ int Mus_StartLump(lumpnum_t lumpNum, dd_bool looped, dd_bool canPlayMUS)
size_t const lumpLength = App_FileSystem().lump(lumpNum).size();
uint8_t *buf = (uint8_t *) M_Malloc(lumpLength);
int lumpIdx;
de::File1 *file = F_FindFileForLumpNum(lumpNum, &lumpIdx);
File1 *file = F_FindFileForLumpNum(lumpNum, &lumpIdx);

F_ReadLumpSection(file, lumpIdx, buf, 0, lumpLength);
M_Mus2Midi((void *)buf, lumpLength, Str_Text(srcFile));
Expand Down
18 changes: 9 additions & 9 deletions doomsday/client/src/dd_main.cpp
Expand Up @@ -119,7 +119,7 @@ class ZipFileType : public de::NativeFileType
addKnownExtension(".zip");
}

de::File1 *interpret(de::FileHandle &hndl, String path, FileInfo const &info) const
File1 *interpret(FileHandle &hndl, String path, FileInfo const &info) const
{
if(Zip::recognise(hndl))
{
Expand All @@ -139,7 +139,7 @@ class WadFileType : public de::NativeFileType
addKnownExtension(".wad");
}

de::File1 *interpret(de::FileHandle &hndl, String path, FileInfo const &info) const
File1 *interpret(FileHandle &hndl, String path, FileInfo const &info) const
{
if(Wad::recognise(hndl))
{
Expand All @@ -164,7 +164,7 @@ static void DD_AutoLoad();
*
* @return @c true iff the referenced file was loaded.
*/
static de::File1 *tryLoadFile(de::Uri const &path, size_t baseOffset = 0);
static File1 *tryLoadFile(de::Uri const &path, size_t baseOffset = 0);

int isDedicated;

Expand Down Expand Up @@ -833,7 +833,7 @@ static void loadResource(ResourceManifest &manifest)
de::Uri path(manifest.resolvedPath(false/*do not locate resource*/), RC_NULL);
if(path.isEmpty()) return;

if(de::File1 *file = tryLoadFile(path, 0/*base offset*/))
if(File1 *file = tryLoadFile(path, 0/*base offset*/))
{
// Mark this as an original game resource.
file->setCustom(false);
Expand Down Expand Up @@ -1076,7 +1076,7 @@ static void initPathLumpMappings()
lumpIndex.findAll("DD_DIREC", foundDirecs);
DENG2_FOR_EACH_CONST(LumpIndex::FoundIndices, i, foundDirecs) // in load order
{
de::File1 &lump = lumpIndex[*i];
File1 &lump = lumpIndex[*i];
FileInfo const &lumpInfo = lump.info();

// Make a copy of it so we can ensure it ends in a null.
Expand Down Expand Up @@ -2149,7 +2149,7 @@ static int DD_StartupWorker(void * /*context*/)
String foundPath = App_FileSystem().findPath(de::Uri("doomsday.pk3", RC_PACKAGE),
RLF_DEFAULT, App_ResourceClass(RC_PACKAGE));
foundPath = App_BasePath() / foundPath; // Ensure the path is absolute.
de::File1 *loadedFile = tryLoadFile(de::Uri(foundPath, RC_NULL));
File1 *loadedFile = tryLoadFile(de::Uri(foundPath, RC_NULL));
DENG2_ASSERT(loadedFile != 0);
DENG2_UNUSED(loadedFile);

Expand Down Expand Up @@ -2850,11 +2850,11 @@ D_CMD(Load)
return didLoadGame || didLoadResource;
}

static de::File1 *tryLoadFile(de::Uri const &search, size_t baseOffset)
static File1 *tryLoadFile(de::Uri const &search, size_t baseOffset)
{
try
{
de::FileHandle& hndl = App_FileSystem().openFile(search.path(), "rb", baseOffset, false /* no duplicates */);
FileHandle& hndl = App_FileSystem().openFile(search.path(), "rb", baseOffset, false /* no duplicates */);

de::Uri foundFileUri = hndl.file().composeUri();
LOG_VERBOSE("Loading \"%s\"...") << NativePath(foundFileUri.asText()).pretty().toUtf8().constData();
Expand All @@ -2878,7 +2878,7 @@ static bool tryUnloadFile(de::Uri const &search)
{
try
{
de::File1 &file = App_FileSystem().find(search);
File1 &file = App_FileSystem().find(search);
de::Uri foundFileUri = file.composeUri();
NativePath nativePath(foundFileUri.asText());

Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/dd_wad.cpp
Expand Up @@ -85,7 +85,7 @@ AutoStr *W_LumpSourceFile(lumpnum_t lumpNum)
{
try
{
de::File1 const &container = App_FileSystem().lump(lumpNum).container();
File1 const &container = App_FileSystem().lump(lumpNum).container();
return AutoStr_FromText(container.composePath().toUtf8().constData());
}
catch(LumpIndex::NotFoundError const &er)
Expand Down Expand Up @@ -138,7 +138,7 @@ size_t W_ReadLump(lumpnum_t lumpNum, uint8_t *buffer)
{
try
{
de::File1 &lump = App_FileSystem().lump(lumpNum);
File1 &lump = App_FileSystem().lump(lumpNum);
return lump.read(buffer, 0, lump.size());
}
catch(LumpIndex::NotFoundError const &er)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/gl/gl_texmanager.cpp
Expand Up @@ -291,7 +291,7 @@ static res::Source loadRaw(image_t &image, rawtex_t const &raw)

try
{
de::FileHandle &file = fileSys.openLump(fileSys.lump(raw.lumpNum));
FileHandle &file = fileSys.openLump(fileSys.lump(raw.lumpNum));
if(Image_LoadFromFile(image, file))
{
fileSys.releaseFile(file.file());
Expand Down
10 changes: 5 additions & 5 deletions doomsday/client/src/resource/bitmapfont.cpp
Expand Up @@ -31,14 +31,14 @@

using namespace de;

static byte inByte(de::FileHandle *file)
static byte inByte(FileHandle *file)
{
byte b;
file->read((uint8_t *)&b, sizeof(b));
return b;
}

static ushort inShort(de::FileHandle *file)
static ushort inShort(FileHandle *file)
{
ushort s;
file->read((uint8_t *)&s, sizeof(s));
Expand Down Expand Up @@ -112,7 +112,7 @@ DENG2_PIMPL(BitmapFont)
return accumSize / glyphCount;
}

uint8_t *readFormat0(de::FileHandle *file)
uint8_t *readFormat0(FileHandle *file)
{
DENG2_ASSERT(file != 0);

Expand Down Expand Up @@ -167,7 +167,7 @@ DENG2_PIMPL(BitmapFont)
return (uint8_t *)image;
}

uint8_t *readFormat2(de::FileHandle *file)
uint8_t *readFormat2(FileHandle *file)
{
DENG2_ASSERT(file != 0);

Expand Down Expand Up @@ -298,7 +298,7 @@ void BitmapFont::glInit()
{
// Relative paths are relative to the native working directory.
String path = (NativePath::workPath() / NativePath(d->filePath).expand()).withSeparators('/');
de::FileHandle *hndl = &App_FileSystem().openFile(path, "rb");
FileHandle *hndl = &App_FileSystem().openFile(path, "rb");

int format = inByte(hndl);

Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/resource/compositetexture.cpp
Expand Up @@ -221,7 +221,7 @@ CompositeTexture *CompositeTexture::constructFrom(de::Reader &reader,
/// There is now one more found component.
foundComponentCount += 1;

de::File1 &file = App_FileSystem().lump(comp.lumpNum());
File1 &file = App_FileSystem().lump(comp.lumpNum());

// If this a "custom" component - the whole texture is.
if(file.container().hasCustom())
Expand Down
42 changes: 21 additions & 21 deletions doomsday/client/src/resource/image.cpp
Expand Up @@ -58,29 +58,29 @@ struct GraphicFileType
/// Known file extension.
String ext;

bool (*interpretFunc)(de::FileHandle &hndl, String filePath, image_t &img);
bool (*interpretFunc)(FileHandle &hndl, String filePath, image_t &img);

char const *(*getLastErrorFunc)(); ///< Can be NULL.
};

static bool interpretPcx(de::FileHandle &hndl, String /*filePath*/, image_t &img)
static bool interpretPcx(FileHandle &hndl, String /*filePath*/, image_t &img)
{
Image_Init(img);
img.pixels = PCX_Load(hndl, img.size, img.pixelSize);
return (0 != img.pixels);
}

static bool interpretJpg(de::FileHandle &hndl, String /*filePath*/, image_t &img)
static bool interpretJpg(FileHandle &hndl, String /*filePath*/, image_t &img)
{
return Image_LoadFromFileWithFormat(img, "JPG", hndl);
}

static bool interpretPng(de::FileHandle &hndl, String /*filePath*/, image_t &img)
static bool interpretPng(FileHandle &hndl, String /*filePath*/, image_t &img)
{
return Image_LoadFromFileWithFormat(img, "PNG", hndl);
}

static bool interpretTga(de::FileHandle &hndl, String /*filePath*/, image_t &img)
static bool interpretTga(FileHandle &hndl, String /*filePath*/, image_t &img)
{
Image_Init(img);
img.pixels = TGA_Load(hndl, img.size, img.pixelSize);
Expand Down Expand Up @@ -114,7 +114,7 @@ static GraphicFileType const *guessGraphicFileTypeFromFileName(String fileName)
return 0; // Unknown.
}

static void interpretGraphic(de::FileHandle &hndl, String filePath, image_t &img)
static void interpretGraphic(FileHandle &hndl, String filePath, image_t &img)
{
// Firstly try the interpreter for the guessed resource types.
GraphicFileType const *rtypeGuess = guessGraphicFileTypeFromFileName(filePath);
Expand Down Expand Up @@ -270,7 +270,7 @@ bool Image_HasAlpha(image_t const &img)
return false;
}

uint8_t *Image_LoadFromFile(image_t &img, de::FileHandle &file)
uint8_t *Image_LoadFromFile(image_t &img, FileHandle &file)
{
#ifdef __CLIENT__
LOG_AS("Image_LoadFromFile");
Expand Down Expand Up @@ -320,7 +320,7 @@ uint8_t *Image_LoadFromFile(image_t &img, de::FileHandle &file)
#endif
}

bool Image_LoadFromFileWithFormat(image_t &img, char const *format, de::FileHandle &hndl)
bool Image_LoadFromFileWithFormat(image_t &img, char const *format, FileHandle &hndl)
{
#ifdef __CLIENT__
LOG_AS("Image_LoadFromFileWithFormat");
Expand Down Expand Up @@ -414,7 +414,7 @@ uint8_t *GL_LoadImage(image_t &image, String nativePath)
// Relative paths are relative to the native working directory.
String path = (NativePath::workPath() / NativePath(nativePath).expand()).withSeparators('/');

de::FileHandle &hndl = App_FileSystem().openFile(path, "rb");
FileHandle &hndl = App_FileSystem().openFile(path, "rb");
uint8_t *pixels = Image_LoadFromFile(image, hndl);

App_FileSystem().releaseFile(hndl.file());
Expand Down Expand Up @@ -587,7 +587,7 @@ static Block loadAndTranslatePatch(IByteArray const &data, colorpaletteid_t palI
}
}

static Source loadPatch(image_t &image, de::FileHandle &hndl, int tclass = 0,
static Source loadPatch(image_t &image, FileHandle &hndl, int tclass = 0,
int tmap = 0, int border = 0)
{
LOG_AS("image_t::loadPatch");
Expand All @@ -597,7 +597,7 @@ static Source loadPatch(image_t &image, de::FileHandle &hndl, int tclass = 0,
return External;
}

de::File1 &file = hndl.file();
File1 &file = hndl.file();
ByteRefArray fileData = ByteRefArray(file.cache(), file.size());

// A DOOM patch?
Expand Down Expand Up @@ -655,7 +655,7 @@ static Source loadPatchComposite(image_t &image, Texture const &tex,
CompositeTexture const &texDef = *reinterpret_cast<CompositeTexture *>(tex.userDataPointer());
DENG2_FOR_EACH_CONST(CompositeTexture::Components, i, texDef.components())
{
de::File1 &file = App_FileSystem().lump(i->lumpNum());
File1 &file = App_FileSystem().lump(i->lumpNum());
ByteRefArray fileData = ByteRefArray(file.cache(), file.size());

// A DOOM patch?
Expand Down Expand Up @@ -697,7 +697,7 @@ static Source loadPatchComposite(image_t &image, Texture const &tex,
return Original;
}

static Source loadFlat(image_t &image, de::FileHandle &hndl)
static Source loadFlat(image_t &image, FileHandle &hndl)
{
if(Image_LoadFromFile(image, hndl))
{
Expand All @@ -712,7 +712,7 @@ static Source loadFlat(image_t &image, de::FileHandle &hndl)
image.pixelSize = 1;
image.paletteId = App_ResourceSystem().defaultColorPalette();

de::File1 &file = hndl.file();
File1 &file = hndl.file();
size_t fileLength = hndl.length();

size_t bufSize = de::max(fileLength, (size_t) image.size.x * image.size.y);
Expand All @@ -728,7 +728,7 @@ static Source loadFlat(image_t &image, de::FileHandle &hndl)
return Original;
}

static Source loadDetail(image_t &image, de::FileHandle &hndl)
static Source loadDetail(image_t &image, FileHandle &hndl)
{
if(Image_LoadFromFile(image, hndl))
{
Expand All @@ -739,7 +739,7 @@ static Source loadDetail(image_t &image, de::FileHandle &hndl)
Image_Init(image);

// How big is it?
de::File1 &file = hndl.file();
File1 &file = hndl.file();
size_t fileLength = hndl.length();
switch(fileLength)
{
Expand Down Expand Up @@ -821,7 +821,7 @@ Source GL_LoadSourceImage(image_t &image, Texture const &tex,
try
{
lumpnum_t const lumpNum = resourceUri.path().toString().toInt();
de::FileHandle &hndl = fileSys.openLump(fileSys.lump(lumpNum));
FileHandle &hndl = fileSys.openLump(fileSys.lump(lumpNum));

source = loadFlat(image, hndl);

Expand Down Expand Up @@ -860,7 +860,7 @@ Source GL_LoadSourceImage(image_t &image, Texture const &tex,
try
{
lumpnum_t const lumpNum = resourceUri.path().toString().toInt();
de::FileHandle &hndl = fileSys.openLump(fileSys.lump(lumpNum));
FileHandle &hndl = fileSys.openLump(fileSys.lump(lumpNum));

source = loadPatch(image, hndl, tclass, tmap, vspec.border);

Expand Down Expand Up @@ -913,7 +913,7 @@ Source GL_LoadSourceImage(image_t &image, Texture const &tex,
try
{
lumpnum_t const lumpNum = resourceUri.path().toString().toInt();
de::FileHandle &hndl = fileSys.openLump(fileSys.lump(lumpNum));
FileHandle &hndl = fileSys.openLump(fileSys.lump(lumpNum));

source = loadPatch(image, hndl, tclass, tmap, vspec.border);

Expand All @@ -940,8 +940,8 @@ Source GL_LoadSourceImage(image_t &image, Texture const &tex,
lumpnum_t const lumpNum = fileSys.lumpNumForName(resourceUri.path());
try
{
de::File1 &lump = fileSys.lump(lumpNum);
de::FileHandle &hndl = fileSys.openLump(lump);
File1 &lump = fileSys.lump(lumpNum);
FileHandle &hndl = fileSys.openLump(lump);

source = loadDetail(image, hndl);

Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/resource/manifest.cpp
Expand Up @@ -182,7 +182,7 @@ static bool validateWad(String const &filePath, QStringList const &identityKeys)
bool validated = true;
try
{
de::FileHandle &hndl = App_FileSystem().openFile(filePath, "rb", 0/*baseOffset*/, true /*allow duplicates*/);
FileHandle &hndl = App_FileSystem().openFile(filePath, "rb", 0/*baseOffset*/, true /*allow duplicates*/);

if(Wad *wad = hndl.file().maybeAs<Wad>())
{
Expand Down Expand Up @@ -235,7 +235,7 @@ static bool validateZip(String const &filePath, QStringList const & /*identityKe
{
try
{
de::FileHandle &hndl = App_FileSystem().openFile(filePath, "rbf");
FileHandle &hndl = App_FileSystem().openFile(filePath, "rbf");
bool result = Zip::recognise(hndl);
/// @todo Check files. We should implement an auxiliary zip lump index...
App_FileSystem().releaseFile(hndl.file());
Expand Down

0 comments on commit fdc8566

Please sign in to comment.