예제 #1
0
bool Utils::mkdir(const std::string &path)
{
    size_t pos = path.find('/');
    while (pos != std::string::npos)
    {
        
        //for unix-like systems
        if (pos != 0)
        {
            std::string dir = path.substr(0, pos);
            if (!isDirExist(dir))
            {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
                if (0 != _mkdir(dir.c_str()) && !isDirExist(dir))
#else
                if (0 != mkdir(dir.c_str()) && !isDirExist(dir))
#endif
                {
                    CCLOG("mkdir %s error: %s", dir.c_str(), strerror(errno));
                    return false;
                }
            }
        }
        pos = path.find('/', pos+1);
    }
    
    return true;
}
예제 #2
0
/*---------------------------------------------------------------------*//**
	ディレクトリの有無を調べる
**//*---------------------------------------------------------------------*/
bool File::isDirExist(const TCHAR* pathDir)
{
#if defined(UNICODE)
	VwString wstrDirPath(pathDir);
	UnicodeTxt wtxtDirPath;
	SjisTxt stxtDirPath;
	wtxtDirPath.setString(&wstrDirPath, UnicodeTxt::F_REF_STRING);
	TxtUtils::convEncode(&stxtDirPath, &wtxtDirPath);
	return isDirExist(stxtDirPath.getRawString());
#else
	return isDirExist(&CcString(pathDir));
#endif
}
예제 #3
0
NimbleStore::NimbleStore(char *path) {
    bool dirExist;
    dirExist = isDirExist(path);
    if(!dirExist) {
        printf("data dir is not exist\n");
        exit(-1);
    }
    for(int i = 0;i < CHUNKNUM;i++){
        char * tempPAth = (char*)malloc(100);
        sprintf(tempPAth,"%s/%d",path,i);
       // printf("%s\n",tempPAth);
        int fd = open(tempPAth,O_CREAT|O_RDWR|O_APPEND,0666);
        fdArry[i] = fd;
       // printf("fd is %d \n",fdArry[i]);
    }
}