issue #1263: Removed CCFileUtils::ccLoadFileIntoMemory in CCFileUtils.mm. Removed some comments.

This commit is contained in:
James Chen 2012-05-28 14:14:19 +08:00
parent 1b7cc47a34
commit 99dcb4de86
4 changed files with 4 additions and 36 deletions

View File

@ -217,35 +217,6 @@ void CCFileUtils::setResourcePath(const char *pszResourcePath)
assert(0);
}
int CCFileUtils::ccLoadFileIntoMemory(const char *filename, unsigned char **out)
{
CCAssert( out, "ccLoadFileIntoMemory: invalid 'out' parameter");
CCAssert( &*out, "ccLoadFileIntoMemory: invalid 'out' parameter");
size_t size = 0;
FILE *f = fopen(filename, "rb");
if( !f ) {
*out = NULL;
return -1;
}
fseek(f, 0, SEEK_END);
size = ftell(f);
fseek(f, 0, SEEK_SET);
*out = (unsigned char*)malloc(size);
size_t read = fread(*out, 1, size, f);
if( read != size ) {
free(*out);
*out = NULL;
return -1;
}
fclose(f);
return size;
}
std::string& CCFileUtils::removeSuffixFromFile(std::string& cpath )
{
NSString *ret = nil;

View File

@ -250,17 +250,14 @@ void ScriptingCore::runScript(const char *path)
#else
const char *realPath = CCFileUtils::fullPathFromRelativePath(path);
#endif
const char *content = NULL;
//cjh size_t contentSize = CCFileUtils::ccLoadFileIntoMemory(realPath, &content);
content = CCString::stringWithContentsOfFile(realPath)->getCString();
if (content/* && contentSize*/) {
const char* content = CCString::stringWithContentsOfFile(realPath)->getCString();
if (content && strlen(content) > 0) {
JSBool ok;
jsval rval;
ok = JS_EvaluateScript(this->cx, this->global, (char *)content, strlen(content), path, 1, &rval);
if (ok == JS_FALSE) {
CCLog("error evaluating script:\n%s", content);
}
//cjh free(content);
}
}

View File

@ -1 +1 @@
8a1763799207ad5aec622e3b0d073ef58294a909
de658072145651c5caa286fe4d10048e06f04e05

View File

@ -1 +1 @@
8ab5af11b4002da68221bf087d3f014941d4be35
f15b1b846b94b2d2b69438899124884963fd9f09