예제 #1
0
const char *CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile)
{
	_CheckPath();
	std::string relativeFile = fullPathFromRelativePath(pszRelativeFile);
	NSString *pRet = new NSString();
	pRet->autorelease();
	pRet->m_sString = relativeFile.substr(0, relativeFile.rfind('/')+1);
	pRet->m_sString += pszFilename;
	return pRet->m_sString.c_str();
}
/*********************************************************************
*
*       _GetPathToFontData
*/
static int _GetPathToFontData(char * pPath) {
  char acPath[_MAX_PATH];
  char acDrive[_MAX_PATH];
  char acDir[_MAX_PATH];

  strcpy(pPath, "C:\\Work\\emWin\\ThirdParty\\iType");
  strcpy(acPath, pPath);
  strcat(acPath, "\\FontData\\Standard");
  if (_CheckPath(acPath)) {
    GetModuleFileName(0, pPath, _MAX_PATH);
    _splitpath(pPath, acDrive, acDir, NULL, NULL);
    _makepath(pPath, acDrive, acDir, NULL, NULL);
    *(pPath + strlen(pPath) - 1) = 0;
    strcpy(acPath, pPath);
    strcat(acPath, "\\FontData\\Standard");
    if (_CheckPath(acPath)) {
      MessageBox(0, acPath, "Path not found:", MB_OK);
      return 1;
    }
  }
  return 0;
}
예제 #3
0
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
{
	_CheckPath();

    CCString * pRet = new CCString();
    pRet->autorelease();
    if ((strlen(pszRelativePath) > 1 && pszRelativePath[1] == ':'))
    {
        pRet->m_sString = pszRelativePath;
    }
    else if (strlen(pszRelativePath) > 0 && pszRelativePath[0] == '/')
    {
		char szDriver[3] = {s_pszResourcePath[0], s_pszResourcePath[1], 0};
        pRet->m_sString = szDriver;
        pRet->m_sString += pszRelativePath;
    }
    else
    {
        pRet->m_sString = s_pszResourcePath;
        pRet->m_sString += pszRelativePath;
    }
#if (CC_IS_RETINA_DISPLAY_SUPPORTED)
    if (CC_CONTENT_SCALE_FACTOR() != 1.0f)
    {
        std::string hiRes = pRet->m_sString.c_str();
        std::string::size_type pos = hiRes.find_last_of("/\\");
        std::string::size_type dotPos = hiRes.find_last_of(".");
        
        if (std::string::npos != dotPos && dotPos > pos)
        {
            hiRes.insert(dotPos, CC_RETINA_DISPLAY_FILENAME_SUFFIX);
        }
        else
        {
            hiRes.append(CC_RETINA_DISPLAY_FILENAME_SUFFIX);
        }
        DWORD attrib = GetFileAttributesA(hiRes.c_str());
        
        if (attrib != INVALID_FILE_ATTRIBUTES && ! (FILE_ATTRIBUTE_DIRECTORY & attrib))
        {
            pRet->m_sString.swap(hiRes);
        }
    }
#endif
	return pRet->m_sString.c_str();
}
예제 #4
0
const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
{
	_CheckPath();

    NSString * pRet = new NSString();
    pRet->autorelease();
    if ((strlen(pszRelativePath) > 1 && pszRelativePath[1] == ':'))
    {
        pRet->m_sString = pszRelativePath;
    }
    else if (strlen(pszRelativePath) > 0 && pszRelativePath[0] == '/')
    {
		char szDriver[3] = {s_pszResourcePath[0], s_pszResourcePath[1], 0};
        pRet->m_sString = szDriver;
        pRet->m_sString += pszRelativePath;
    }
    else
    {
        pRet->m_sString = s_pszResourcePath;
        pRet->m_sString += pszRelativePath;
    }
	return pRet->m_sString.c_str();
}