本文整理汇总了C++中PackageManager::getFile方法的典型用法代码示例。如果您正苦于以下问题:C++ PackageManager::getFile方法的具体用法?C++ PackageManager::getFile怎么用?C++ PackageManager::getFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PackageManager
的用法示例。
在下文中一共展示了PackageManager::getFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
SWImage::SWImage(const Common::String &filename, bool &result) :
_imageDataPtr(0),
_width(0),
_height(0) {
result = false;
PackageManager *pPackage = Kernel::getInstance()->getPackage();
assert(pPackage);
// Load file
byte *pFileData;
uint fileSize;
pFileData = pPackage->getFile(filename, &fileSize);
if (!pFileData) {
error("File \"%s\" could not be loaded.", filename.c_str());
return;
}
// Uncompress the image
int pitch;
byte *pUncompressedData;
if (!ImgLoader::decodePNGImage(pFileData, fileSize, pUncompressedData, _width, _height, pitch)) {
error("Could not decode image.");
return;
}
// Cleanup FileData
delete[] pFileData;
_imageDataPtr = (uint *)pUncompressedData;
result = true;
return;
}
示例2: readSavegameThumbnail
RenderedImage::RenderedImage(const Common::String &filename, bool &result) :
_data(0),
_width(0),
_height(0),
_isTransparent(true) {
result = false;
PackageManager *pPackage = Kernel::getInstance()->getPackage();
assert(pPackage);
_backSurface = Kernel::getInstance()->getGfx()->getSurface();
// Load file
byte *pFileData;
uint fileSize;
bool isPNG = true;
if (filename.hasPrefix("/saves")) {
pFileData = readSavegameThumbnail(filename, fileSize, isPNG);
} else {
pFileData = pPackage->getFile(filename, &fileSize);
}
if (!pFileData) {
error("File \"%s\" could not be loaded.", filename.c_str());
return;
}
// Uncompress the image
int pitch;
if (isPNG)
result = ImgLoader::decodePNGImage(pFileData, fileSize, _data, _width, _height, pitch);
else
result = ImgLoader::decodeThumbnailImage(pFileData, fileSize, _data, _width, _height, pitch);
if (!result) {
error("Could not decode image.");
delete[] pFileData;
return;
}
// Cleanup FileData
delete[] pFileData;
_doCleanup = true;
#if defined(SCUMM_LITTLE_ENDIAN)
// Makes sense for LE only at the moment
checkForTransparency();
#endif
return;
}
示例3:
SWImage::SWImage(const Common::String &filename, bool &result) :
_imageDataPtr(0),
_width(0),
_height(0) {
result = false;
PackageManager *pPackage = Kernel::getInstance()->getPackage();
assert(pPackage);
// Datei laden
byte *pFileData;
uint fileSize;
pFileData = pPackage->getFile(filename, &fileSize);
if (!pFileData) {
error("File \"%s\" could not be loaded.", filename.c_str());
return;
}
// Bildeigenschaften bestimmen
int pitch;
if (!PNGLoader::imageProperties(pFileData, fileSize, _width, _height)) {
error("Could not read image properties.");
return;
}
// Das Bild dekomprimieren
byte *pUncompressedData;
if (!PNGLoader::decodeImage(pFileData, fileSize, pUncompressedData, _width, _height, pitch)) {
error("Could not decode image.");
return;
}
// Dateidaten freigeben
delete[] pFileData;
_imageDataPtr = (uint *)pUncompressedData;
result = true;
return;
}
示例4: executeFile
bool LuaScriptEngine::executeFile(const Common::String &fileName) {
#ifdef DEBUG
int __startStackDepth = lua_gettop(_state);
#endif
debug(2, "LuaScriptEngine::executeFile(%s)", fileName.c_str());
// Get a pointer to the package manager
PackageManager *pPackage = Kernel::getInstance()->getPackage();
assert(pPackage);
// File read
uint fileSize;
byte *fileData = pPackage->getFile(fileName, &fileSize);
if (!fileData) {
error("Couldn't read \"%s\".", fileName.c_str());
#ifdef DEBUG
assert(__startStackDepth == lua_gettop(_state));
#endif
return false;
}
// Run the file content
if (!executeBuffer(fileData, fileSize, "@" + pPackage->getAbsolutePath(fileName))) {
// Release file buffer
delete[] fileData;
#ifdef DEBUG
assert(__startStackDepth == lua_gettop(_state));
#endif
return false;
}
// Release file buffer
delete[] fileData;
#ifdef DEBUG
assert(__startStackDepth == lua_gettop(_state));
#endif
return true;
}