本文整理汇总了C++中IReadFile::drop方法的典型用法代码示例。如果您正苦于以下问题:C++ IReadFile::drop方法的具体用法?C++ IReadFile::drop怎么用?C++ IReadFile::drop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReadFile
的用法示例。
在下文中一共展示了IReadFile::drop方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeXMLHeader
void IXMLWriterTest::writeXMLHeader()
{
IWriteFile* fWrite = IFileSystem::createWriteFile(
"assets/io/fileXMLEmpty.xml");
IXMLWriter* fxml = IFileSystem::createXMLWriter(fWrite);
if (fWrite)
fWrite->drop();
fxml->writeXMLHeader();
if (fxml)
fxml->drop();
IReadFile* fRead = IFileSystem::createReadFile(
"assets/io/fileXMLEmpty.xml");
IXMLReader* fxmlR = IFileSystem::createXMLReader(fRead);
fxmlR->read();
if (fxmlR->getNodeType() != EXNT_UNKNOWN)
mes.append(
"\n writeXMLHeader: does not write the XMLHeader");
if (fxmlR)
fxmlR->drop();
if (fRead)
fRead->drop();
}
示例2: findFile
//! returns fileindex
s32 CUnZipReader::findFile(const c8* filename)
{
IReadFile *file = openFile ( filename );
if ( 0 == file )
return -1;
file->drop ();
return 1;
}
示例3: createAndOpenFile
//! Creates a XML Reader from a file.
IXMLReaderUTF8* CFileSystem::createXMLReaderUTF8(const c8* filename)
{
IReadFile* file = createAndOpenFile(filename);
if (!file)
return 0;
IXMLReaderUTF8* reader = createIXMLReaderUTF8(file);
file->drop();
return reader;
}
示例4: createXMLReader
//! Creates a XML Reader from a file.
IXMLReader* CFileSystem::createXMLReader(const io::path& filename)
{
IReadFile* file = createAndOpenFile(filename);
if (!file)
return 0;
IXMLReader* reader = createXMLReader(file);
file->drop();
return reader;
}
示例5: createXMLReader
//! Creates a XML Reader from a file.
IXMLReader* CFileSystem::createXMLReader(const core::string<c16>& filename)
{
IReadFile* file = createAndOpenFile(filename);
if (!file)
return 0;
IXMLReader* reader = createXMLReader(file);
file->drop();
return reader;
}
示例6: createArchive
/** \param file File handle to check.
\return Pointer to newly created archive, or 0 upon error. */
IFileArchive* CArchiveLoaderNPK::createArchive(const path& filename, bool ignoreCase, bool ignorePaths) const
{
IFileArchive *archive = 0;
IReadFile* file = FileSystem->createAndOpenFile(filename);
if (file)
{
archive = createArchive(file, ignoreCase, ignorePaths);
file->drop();
}
return archive;
}
示例7: drop
/** See IXMLReader for more information on how to use the parser.
\return 0, if file could not be opened, otherwise a pointer to the created
IXMLReader is returned. After use, the reader
has to be deleted using its IXMLReader::drop() method.
See IReferenceCounted::drop() for more information. */
IXMLReader* SharedFileSystem::createXMLReader(
const core::stringc& filename)
{
// Create the file using an absolute path so that it matches
// the scheme used by CNullDriver::getTexture().
IReadFile * file = createReadFile(this->getAbsolutePath(filename));
IXMLReader* reader = irrgame::io::createXMLReader(file);
if (file)
file->drop();
return reader;
}
示例8: addPakFileArchive
//! adds an pak archive to the filesystem
bool CFileSystem::addPakFileArchive(const c8* filename, bool ignoreCase, bool ignorePaths)
{
CPakReader* zr = 0;
IReadFile* file = createAndOpenFile(filename);
if (file)
{
zr = new CPakReader(file, ignoreCase, ignorePaths);
if (zr)
PakFileSystems.push_back(zr);
file->drop();
}
#ifdef _DEBUG
else
os::Printer::log("Could not open file. Pakfile not added", filename, ELL_ERROR);
#endif
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return (zr != 0);
}
示例9: addZipFileArchive
//! adds an zip archive to the filesystem
bool CFileSystem::addZipFileArchive(const c8* filename, bool ignoreCase, bool ignorePaths)
{
IReadFile* file = createReadFile(filename);
if (file)
{
CZipReader* zr = new CZipReader(file, ignoreCase, ignorePaths);
if (zr)
ZipFileSystems.push_back(zr);
file->drop();
bool ret = (zr != 0);
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return ret;
}
#ifdef _DEBUG
os::Printer::log("Could not open file. Zipfile not added", filename, ELL_ERROR);
#endif
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return false;
}
示例10: disambiguateTextures
bool disambiguateTextures(void)
{
IrrlichtDevice *device =
createDevice( video::EDT_SOFTWARE, dimension2d<s32>(640, 480), 16,
false, false, false, 0);
if (!device)
return false;
IVideoDriver * driver = device->getVideoDriver();
ITexture * tex1 = driver->getTexture("../media/tools.png");
ITexture * tex2 = driver->getTexture("../media/tools.png");
IReadFile * readFile = device->getFileSystem()->createAndOpenFile("../media/tools.png");
assert(readFile);
ITexture * tex3 = driver->getTexture(readFile);
readFile->drop();
// Expects an empty tmp/tmp directory under this app's wd and
// a media directory under this apps' directory with tools.png in it.
stringc wd = device->getFileSystem()->getWorkingDirectory();
stringc newWd = wd + "/empty/empty";
bool changed = device->getFileSystem()->changeWorkingDirectoryTo(newWd.c_str());
assert(changed);
ITexture * tex4 = driver->getTexture("../../media/tools.png");
assert(tex4);
assert(tex1 == tex2 && tex1 == tex3 && tex1 != tex4);
changed &= device->getFileSystem()->changeWorkingDirectoryTo(wd.c_str());
device->drop();
return (changed && tex1 == tex2 && tex1 == tex3 && tex1 != tex4) ? true : false;
}
示例11: disambiguateTextures
/** This tests verifies that textures opened from different places in the filesystem
can be distinguished, even if they have the same filename. */
bool disambiguateTextures(void)
{
IrrlichtDevice *device =
createDevice( video::EDT_NULL, dimension2d<s32>(640, 480));
if (!device)
{
logTestString("Unable to create EDT_NULL device\n");
return false;
}
// Expects an empty tmp/tmp directory under this app's wd and
// a media directory under this apps' directory with tools.png in it.
stringc wd = device->getFileSystem()->getWorkingDirectory();
if(-1 == wd.find("/tests") && -1 == wd.find("\\tests"))
{
logTestString("The tests must be run from the /tests directory, regardless of where\n"\
"the test executable was built.\n");
device->drop();
return false;
}
IVideoDriver * driver = device->getVideoDriver();
ITexture * tex1 = driver->getTexture("../media/tools.png");
assert(tex1);
if(!tex1)
logTestString("Unable to open ../media/tools.png\n");
ITexture * tex2 = driver->getTexture("../media/tools.png");
assert(tex2);
if(!tex2)
logTestString("Unable to open ../media/tools.png\n");
IReadFile * readFile = device->getFileSystem()->createAndOpenFile("../media/tools.png");
assert(readFile);
if(!readFile)
logTestString("Unable to open ../media/tools.png\n");
ITexture * tex3 = driver->getTexture(readFile);
assert(tex3);
if(!readFile)
logTestString("Unable to create texture from ../media/tools.png\n");
readFile->drop();
// All 3 of the above textures should be identical.
assert(tex1 == tex2 && tex1 == tex3);
stringc newWd = wd + "/empty/empty";
bool changed = device->getFileSystem()->changeWorkingDirectoryTo(newWd.c_str());
assert(changed);
ITexture * tex4 = driver->getTexture("../../media/tools.png");
assert(tex4);
if(!tex4)
logTestString("Unable to open ../../media/tools.png\n");
assert(tex1 != tex4);
// The working directory must be restored for the other tests to work.
changed &= device->getFileSystem()->changeWorkingDirectoryTo(wd.c_str());
device->drop();
return (changed && tex1 == tex2 && tex1 == tex3 && tex1 != tex4) ? true : false;
}
示例12: main
int main(int argc, char **argv) {
// Help?
if (argv[1] && argv[1][0] == '-') die(helpmsg);
putenv((char *) "vblank_mode=0"); // No vsync for us, thanks.
MyEventReceiver *r = new MyEventReceiver();
IrrlichtDevice *dev = createDevice(EDT_OPENGL, core::dimension2d<u32>(1024,768), 32,
false, false, false, r);
if (!dev) die("Can't initialize Irrlicht");
IVideoDriver *drv = dev->getVideoDriver();
ISceneManager *smgr = dev->getSceneManager();
IGPUProgrammingServices *gpu = drv->getGPUProgrammingServices();
ICameraSceneNode *cam = NULL;
ITexture *pic = NULL;
IMeshSceneNode *ball = NULL;
bool showpic = false;
IReadFile *areamap = createMemoryReadFile(AreaMap33, sizeof(AreaMap33), "AreaMap33", false);
if (!areamap) die("Failed to load areamap");
ITexture *areamaptex = drv->getTexture(areamap);
areamap->drop();
// If there's an argument, assume it is a pic to load; otherwise, draw a sphere
if (argv[1] && access(argv[1], R_OK) == 0) {
showpic = true;
pic = drv->getTexture(argv[1]);
if (!pic) die("Can't load image");
cam = smgr->addCameraSceneNode();
} else {
cam = smgr->addCameraSceneNodeMaya();
cam->setTarget(vector3df(0, 0, 0));
ball = smgr->addSphereSceneNode(40, 8);
int ballshader = gpu->addHighLevelShaderMaterial(rnd,0,EVST_VS_1_1,0);
ball->setMaterialType((E_MATERIAL_TYPE) ballshader);
ISceneNodeAnimator *cool = smgr->createRotationAnimator(vector3df(-0.1, 0.1, -0.1));
ball->addAnimator(cool);
cool->drop();
}
// Set up static defines, RTTs, quads
dimension2d<u32> screensize = drv->getScreenSize();
char defines[128];
snprintf(defines, 128,
"#define PIXEL_SIZE vec2(1.0f / %u.0, 1.0f / %u.0)\n"
"#define MAX_SEARCH_STEPS 8.0\n#define MAX_DISTANCE 33.0\n",
screensize.Width, screensize.Height);
ITexture *rt1 = drv->addRenderTargetTexture(screensize, "rt1", ECF_A8R8G8B8);
ITexture *rt2 = drv->addRenderTargetTexture(screensize, "rt2", ECF_A8R8G8B8);
ITexture *rt3 = drv->addRenderTargetTexture(screensize, "rt3", ECF_A8R8G8B8);
if (!rt1 || !rt2 || !rt3) die("No RTT");
ScreenQuad *def = new ScreenQuad(drv);
ScreenQuad *sq = new ScreenQuad(drv);
ScreenQuad *sq2 = new ScreenQuad(drv);
ScreenQuad *sq3 = new ScreenQuad(drv);
ScreenQuad *norm = new ScreenQuad(drv);
if (showpic) def->SetTexture(pic);
sq->SetTexture(rt1);
sq->GetMaterial().setFlag(EMF_BILINEAR_FILTER, false);
norm->SetTexture(rt1);
norm->GetMaterial().setFlag(EMF_BILINEAR_FILTER, false);
sq2->SetTexture(rt2);
sq2->SetTexture(rt2, 1);
sq2->SetTexture(areamaptex, 2);
sq2->GetMaterial().TextureLayer[2].BilinearFilter = false;
sq3->SetTexture(rt3);
sq3->GetMaterial().setFlag(EMF_BILINEAR_FILTER, false);
sq3->SetTexture(rt1,1);
state_t state = MLAA_OFF;
stringc tmp1, tmp2;
tmp1 = defines;
tmp1 += offsetvs;
tmp2 = defines;
tmp2 += color1fs;
// Load shaders
int edge = gpu->addHighLevelShaderMaterial(tmp1.c_str(),0,EVST_VS_1_1,tmp2.c_str());
sq->SetMaterialType((E_MATERIAL_TYPE) edge);
tmp2 = defines;
tmp2 += blend2fs;
blendcb *bcb = new blendcb();
edge = gpu->addHighLevelShaderMaterial(tmp1.c_str(),0,EVST_VS_1_1,tmp2.c_str(),0,EPST_PS_1_1,bcb);
sq2->SetMaterialType((E_MATERIAL_TYPE) edge);
tmp2 = defines;
tmp2 += neigh3fs;
//.........这里部分代码省略.........
示例13: loadFromFileFolder
/** This tests verifies that textures opened from different places in the
filesystem don't create duplicated textures. */
bool loadFromFileFolder(void)
{
IrrlichtDevice *device =
createDevice( video::EDT_NULL, dimension2du(160, 120));
if (!device)
{
logTestString("Unable to create EDT_NULL device\n");
return false;
}
IVideoDriver * driver = device->getVideoDriver();
u32 numTexs = driver->getTextureCount();
ITexture * tex1 = driver->getTexture("../media/tools.png");
assert_log(tex1);
if(!tex1)
logTestString("Unable to open ../media/tools.png\n");
if (driver->getTextureCount()!=numTexs+1)
{
logTestString("No additional texture in the texture cache %s:%d\n", __FILE__, __LINE__);
return false;
}
IReadFile * readFile = device->getFileSystem()->createAndOpenFile("../media/tools.png");
assert_log(readFile);
if(!readFile)
logTestString("Unable to open ../media/tools.png\n");
if (driver->getTextureCount()!=numTexs+1)
{
logTestString("Additional texture in the texture cache %s:%d\n", __FILE__, __LINE__);
return false;
}
ITexture * tex2 = driver->getTexture(readFile);
assert_log(tex2);
if(!readFile)
logTestString("Unable to create texture from ../media/tools.png\n");
if (driver->getTextureCount()!=numTexs+1)
{
logTestString("Additional texture in the texture cache %s:%d\n", __FILE__, __LINE__);
return false;
}
readFile->drop();
// adding a folder archive
device->getFileSystem()->addFileArchive( "../media/" );
ITexture * tex3 = driver->getTexture("tools.png");
assert_log(tex3);
if(!tex3)
logTestString("Unable to open tools.png\n");
if (driver->getTextureCount()!=numTexs+1)
{
logTestString("Additional texture in the texture cache %s:%d\n", __FILE__, __LINE__);
return false;
}
ITexture * tex4 = driver->getTexture("tools.png");
assert_log(tex4);
if(!tex4)
logTestString("Unable to open tools.png\n");
if (driver->getTextureCount()!=numTexs+1)
{
logTestString("Additional texture in the texture cache %s:%d\n", __FILE__, __LINE__);
return false;
}
device->closeDevice();
device->run();
device->drop();
return ((tex1 == tex2) && (tex1 == tex3) && (tex1 == tex4));
}
示例14: writeElement
void IXMLWriterTest::writeElement()
{
IWriteFile* fWrite = IFileSystem::createWriteFile(
"assets/io/fileXMLEmpty.xml");
IXMLWriter* fxml = IFileSystem::createXMLWriter(fWrite);
if (fWrite)
fWrite->drop();
fxml->writeElement("fff", true, "attr1", "attrValue1");
if (fxml)
fxml->drop();
IReadFile* fRead = IFileSystem::createReadFile(
"assets/io/fileXMLEmpty.xml");
IXMLReader* fxmlR = IFileSystem::createXMLReader(fRead);
fxmlR->read();
if (fxmlR->getNodeType() != EXNT_ELEMENT)
mes.append(
"\n writeElement: incorrectly indicates the type of node");
if (fxmlR->getAttributeCount() != 1)
mes.append(
"\n writeElement: correctly returns the number of attributes");
core::stringc strA = core::stringc("attr1");
if (!strA.equalsn(fxmlR->getAttributeName(0), 4))
mes.append(
"\n writeElement: correctly returns the name of attributes");
core::stringc strV = core::stringc("attrValue1");
if (!strV.equalsn(fxmlR->getAttributeValue(0), 10))
mes.append(
"\n writeElement: correctly returns the value of attributes");
if (fxmlR)
fxmlR->drop();
if (fRead)
fRead->drop();
//TODO should not create an element with no name
IWriteFile* fWrite1 = IFileSystem::createWriteFile(
"assets/io/fileXMLEmpty.xml");
IXMLWriter* fxml1 = IFileSystem::createXMLWriter(fWrite1);
if (fWrite1)
fWrite1->drop();
fxml1->writeElement("", true);
if (fxml1)
fxml1->drop();
IReadFile* fRead1 = IFileSystem::createReadFile(
"assets/io/fileXMLEmpty.xml");
IXMLReader* fxmlR1 = IFileSystem::createXMLReader(fRead1);
fxmlR1->read();
core::stringc strN = core::stringc("");
if (strN.equalsn(fxmlR1->getNodeName(), 1))
mes.append("\n writeElement: node name can not be empty");
if (fxmlR1->getAttributeCount() != 0)
mes.append("\n writeElement: sees non-existent attributes");
if (fxmlR1)
fxmlR1->drop();
if (fRead1)
fRead1->drop();
core::array<core::stringc> atr;
atr.insert(core::stringc("atr1"));
atr.insert(core::stringc("atr2"));
atr.insert(core::stringc("7"));
atr.insert(core::stringc(0));
atr.insert(core::stringc("art5"));
atr.insert(core::stringc("</>"));
atr.insert(core::stringc("art7"));
core::array<core::stringc> atrValue;
atrValue.insert(core::stringc("atrValue1"));
atrValue.insert(core::stringc("atrValue2"));
atrValue.insert(core::stringc("atrValue3"));
atrValue.insert(core::stringc("atrValue4"));
atrValue.insert(core::stringc("atrValue5"));
atrValue.insert(core::stringc("6"));
atrValue.insert(core::stringc(""));
IWriteFile* fWrite3 = IFileSystem::createWriteFile(
"assets/io/fileXMLEmpty.xml");
IXMLWriter* fxml3 = IFileSystem::createXMLWriter(fWrite3);
if (fWrite3)
fWrite3->drop();
fxml3->writeElement("fff", true, atr, atrValue);
if (fxml3)
//.........这里部分代码省略.........