本文整理汇总了C++中CCFileUtils::isFileExist方法的典型用法代码示例。如果您正苦于以下问题:C++ CCFileUtils::isFileExist方法的具体用法?C++ CCFileUtils::isFileExist怎么用?C++ CCFileUtils::isFileExist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCFileUtils
的用法示例。
在下文中一共展示了CCFileUtils::isFileExist方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: validate
bool ProjectConfig::validate(void)
{
CCFileUtils *utils = CCFileUtils::sharedFileUtils();
if (!utils->isDirectoryExist(m_projectDir)) return false;
if (!utils->isDirectoryExist(getWritableRealPath())) return false;
if (!utils->isFileExist(getScriptFileRealPath())) return false;
return true;
}
示例2: onEnter
void TestIsFileExist::onEnter()
{
FileUtilsDemo::onEnter();
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCFileUtils *sharedFileUtils = CCFileUtils::sharedFileUtils();
CCLabelTTF* pTTF = NULL;
bool isExist = false;
isExist = sharedFileUtils->isFileExist("Images/grossini.png");
pTTF = CCLabelTTF::create(isExist ? "Images/grossini.png exists" : "Images/grossini.png doesn't exist", "", 20);
pTTF->setPosition(ccp(s.width/2, s.height/3));
this->addChild(pTTF);
isExist = sharedFileUtils->isFileExist("Images/grossini.xcf");
pTTF = CCLabelTTF::create(isExist ? "Images/grossini.xcf exists" : "Images/grossini.xcf doesn't exist", "", 20);
pTTF->setPosition(ccp(s.width/2, s.height/3*2));
this->addChild(pTTF);
}
示例3: loader_Android
int loader_Android(lua_State *L)
{
std::string filename(luaL_checkstring(L, 1));
int pos = filename.rfind(".lua");
if (pos != std::string::npos)
{
filename = filename.substr(0, pos);
}
pos = filename.find_first_of(".");
while (pos != std::string::npos)
{
filename.replace(pos, 1, "/");
pos = filename.find_first_of(".");
}
filename.append(".lua");
// search file in package.path
unsigned char* codeBuffer = NULL;
unsigned long codeBufferSize = 0;
std::string codePath;
CCFileUtils* utils = CCFileUtils::sharedFileUtils();
lua_getglobal(L, "package");
lua_getfield(L, -1, "path");
std::string searchpath(lua_tostring(L, -1));
lua_pop(L, 1);
int begin = 0;
int next = searchpath.find_first_of(";", 0);
do
{
if (next == std::string::npos) next = searchpath.length();
std::string prefix = searchpath.substr(begin, next);
if (prefix[0] == '.' && prefix[1] == '/')
{
prefix = prefix.substr(2);
}
pos = prefix.find("?.lua");
codePath = prefix.substr(0, pos).append(filename);
codePath = utils->fullPathForFilename(codePath.c_str());
if (utils->isFileExist(codePath))
{
codeBuffer = utils->getFileData(codePath.c_str(), "rb", &codeBufferSize);
break;
}
begin = next + 1;
next = searchpath.find_first_of(";", begin);
} while (begin < (int)searchpath.length());
if (codeBuffer)
{
if (luaL_loadbuffer(L, (char*)codeBuffer, codeBufferSize, codePath.c_str()) != 0)
{
luaL_error(L, "error loading module %s from file %s :\n\t%s",
lua_tostring(L, 1), filename.c_str(), lua_tostring(L, -1));
}
delete []codeBuffer;
}
else
{
CCLog("can not get file data of %s", filename.c_str());
}
return 1;
}