コード例 #1
0
ファイル: kfilepathmgr.cpp プロジェクト: 1suming/pap2
    bool KFilePathMgr::Init()
    {
        bool bResult = false;
        char szPath[MAX_PATH];
        char szKey[128];
        IIniFile *pIni = NULL;

#ifdef KG_PUBLISH
		pIni = g_OpenIniFileInPak("\\ui\\configfilepath.ini");
		if (!pIni)
			pIni = g_OpenIniFile("\\ui\\configfilepath.ini");
		KGLOG_PROCESS_ERROR(pIni && "open ini file ui\\configfilepath.ini failed!\n");
#else
		pIni = g_OpenIniFile("\\ui\\configfilepath.ini");
		KGLOG_PROCESS_ERROR(pIni && "open ini file ui\\configfilepath.ini failed!\n");
#endif

        szKey[0] = '\0';
    	while (pIni->GetNextKey("FILE_PATH", szKey, szKey))
        {
            pIni->GetString("FILE_PATH", szKey, "", szPath, _countof(szPath));
            FormatFilePath(szPath);

            m_KeyToPath[szKey] = szPath;
        }

        bResult = true;
Exit0:
        SAFE_RELEASE(pIni);
        return bResult;
    }
コード例 #2
0
const char* CMWebImage::GetFilePath(const char* sUrl)
{
    if(sUrl==NULL)
        return NULL;
	FormatFilePath(sUrl);
	if(!CMFile::FileExist(m_sFilePath))
		return NULL;
	return (const char*)m_sFilePath;
}
コード例 #3
0
ファイル: ksystemscripttable.cpp プロジェクト: viticm/pap2
int KSystemScriptTable::LuaLoadDataFromFile(Lua_State* L)
{
    int nRetCode = false;

    IFile *piFile = NULL;
    const char *pcszFile = NULL;
    const char *pcsBuff = NULL;
    size_t uBuffSize = 0;
    int nParamCount = 0;
    char szFilePath[MAX_PATH];

    KGLOG_PROCESS_ERROR(L);

    nRetCode = lua_gettop(L);
    KGLOG_PROCESS_ERROR(nRetCode == 1);

    pcszFile = lua_tostring(L, 1);
    KGLOG_PROCESS_ERROR(pcszFile);

    nRetCode = snprintf(
                   szFilePath,
                   sizeof(szFilePath),
                   "%s\\%s",
                   F_UI_USER_DATA_FOLDER,
                   pcszFile
               );
    KGLOG_PROCESS_ERROR(nRetCode > 0);
    szFilePath[sizeof(szFilePath) - 1] = '\0';
    FormatFilePath(szFilePath);

    nRetCode = KUiConfig::IsFilePathExist(szFilePath);
    KG_PROCESS_SUCCESS(!nRetCode);

    piFile = g_OpenFile(szFilePath, true);
    KGLOG_PROCESS_ERROR(piFile);

    uBuffSize = piFile->Size();
    KGLOG_PROCESS_ERROR(uBuffSize > 0);

    pcsBuff = (const char *)piFile->GetBuffer();
    KGLOG_PROCESS_ERROR(pcsBuff);

    lua_pushlstring(L, pcsBuff, uBuffSize);
    nParamCount++;

Exit1:
Exit0:
    SAFE_RELEASE(piFile);
    return nParamCount;
}
コード例 #4
0
ファイル: kfilepathmgr.cpp プロジェクト: 1suming/pap2
	LPCSTR FormatFilePath(LPCSTR pcszPath)
	{
        //将所有文件名统一换成标准的文件名
        //如:C:\\Kingsoft/MyProject.ini 更换为 c:\\kingsoft\\myproject.ini

		static CHAR szPath[MAX_PATH];

		if (!pcszPath)
			return NULL;
		strncpy(szPath, pcszPath, _countof(szPath));
		szPath[_countof(szPath) - 1] = '\0';
		FormatFilePath(szPath);
		return szPath;
	}
コード例 #5
0
ファイル: itemimage.cpp プロジェクト: 1suming/pap2
int KItemImage::Init(Lua_State *pLua, int nTableIndex)
{
	int nResult  = false;
	int nRetCode = false;

    char szImagePath[MAX_PATH];
    int  nFrame     = 0;
    int  nImageType = 0;

    KLuaTableField aParamTable[] = 
    {
        KLUA_TABLE_FIELD("image",     emVAR_TYPE_STRING, "", szImagePath, _countof(szImagePath)),
        KLUA_TABLE_FIELD("frame",     emVAR_TYPE_INT,    0,  &nFrame,     0),
        KLUA_TABLE_FIELD("ImageType", emVAR_TYPE_INT,    0,  &nImageType, 0),
    };

    KGLOG_PROCESS_ERROR(pLua);

    nRetCode = KItemNull::Init(pLua, nTableIndex);
    KGLOG_PROCESS_ERROR(nRetCode);

    for (int i = 0; i < _countof(aParamTable); i++)
    {
        nRetCode = g_LuaGetTableField(pLua, nTableIndex, &aParamTable[i]);
        KGLOG_PROCESS_ERROR(nRetCode);
    }

    if (szImagePath[0])
    {
        FormatFilePath(szImagePath);
        if (stricmp(szImagePath, "fromiconid") == 0)
            FromIconID(nFrame);
        else
            FromUITex(szImagePath, nFrame);
    }

    if (m_fWidth == 0 && m_fHeight == 0)
        AutoSize();

    SetImageType(nImageType);

// Exit1:
	nResult = true;
Exit0:
	return nResult;
}
コード例 #6
0
void CMWebImage::DownloadNext()
{
    if (CMGlobal::TheOne().IsOffline())
	{
		if(m_pListener)
			m_pListener->OnFinish(m_UserData, MERN_OFFLINE, 0);
        return;
	}
    
	if(!m_pDownloader)
	{
		m_pDownloader = new CMDownloader(this);
#if defined(PLAT_IOS) || defined(PLAT_AND)
		m_pDownloader->SetMaxFileSize(1024*1024);
#else
		m_pDownloader->SetMaxFileSize(512*1024);
#endif
	}

	if(m_pDownloader->GetStatus() == CMDownloader::RUNNING)
		return;

	if(m_lstPicUrl->size() > 0)
	{
		PicUrl* pPicUrl = (PicUrl*)m_lstPicUrl->at(0);
		if(pPicUrl)
		{
			FormatFilePath(pPicUrl->url);
			CMString sID;
			CMGlobal::TheOne().GetSessionID(sID);
			CMString url = pPicUrl->url;		
			INT32 pos = url.ReverseFind(L"?");
			if(pos < 0)
				url += L"?sid=";
			else
				url += L"&sid=";
			url += sID;
		
			m_pDownloader->Download(url, m_sFilePath);
		}
	}
}
コード例 #7
0
			const QByteArray &name = QByteArray()) {
		Expects(!file.relativePath.isEmpty()
			|| file.skipReason != SkipReason::None);

		push(label, [&]() -> QByteArray {
			const auto pre = name.isEmpty() ? QByteArray() : name + ' ';
			switch (file.skipReason) {
			case SkipReason::Unavailable:
				return pre + "(File unavailable, please try again later)";
			case SkipReason::FileSize:
				return pre + "(File exceeds maximum size. "
					"Change data exporting settings to download.)";
			case SkipReason::FileType:
				return pre + "(File not included. "
					"Change data exporting settings to download.)";
			case SkipReason::None: return FormatFilePath(file);
			}
			Unexpected("Skip reason while writing file path.");
		}());
	};
	const auto pushPhoto = [&](const Image &image) {
		pushPath(image.file, "photo");
		if (image.width && image.height) {
			push("width", image.width);
			push("height", image.height);
		}
	};

	message.action.content.match([&](const ActionChatCreate &data) {
		pushActor();
		pushAction("create_group");
コード例 #8
0
ファイル: ksystemscripttable.cpp プロジェクト: viticm/pap2
int KSystemScriptTable::LuaSaveDataToFile(Lua_State* L)
{
    int nRetCode = false;

    IFile *piFile = NULL;
    const char *pcszFile = NULL;
    const char *pcsBuff = NULL;
    unsigned uFilePathLength = 0;
    size_t uBuffSize = 0;
    int i = 0;
    char szFile[MAX_PATH];
    char szPath[MAX_PATH];

    KGLOG_PROCESS_ERROR(L);

    nRetCode = lua_gettop(L);
    KGLOG_PROCESS_ERROR(nRetCode == 2);

    pcsBuff = lua_tolstring(L, 1, &uBuffSize);
    KGLOG_PROCESS_ERROR(pcsBuff);
    KGLOG_PROCESS_ERROR(uBuffSize > 0);

    pcszFile = lua_tostring(L, 2);
    KGLOG_PROCESS_ERROR(pcszFile);
    KGLOG_PROCESS_ERROR(pcszFile[0]);

    uFilePathLength = snprintf(
                          szFile,
                          sizeof(szFile),
                          "%s\\%s",
                          F_UI_USER_DATA_FOLDER,
                          pcszFile
                      );
    KGLOG_PROCESS_ERROR(uFilePathLength > 0);
    szFile[sizeof(szFile) - 1] = '\0';
    FormatFilePath(szFile);

    szPath[0] = '\0';
    for (i = uFilePathLength; i >= 0; i--)
    {
        if (szFile[i] != '/' && szFile[i] != '\\')
            continue;

        ASSERT(i < sizeof(szPath));
        strncpy(szPath, szFile, i);
        szPath[i] = '\0';
        break;
    }

    nRetCode = KUiConfig::IsFilePathExist(szPath);
    if (!nRetCode)
    {
        nRetCode = KUiConfig::CreatePath(szPath);
        KGLOG_PROCESS_ERROR(nRetCode);
    }

    piFile = g_CreateFile(szFile);
    KGLOG_PROCESS_ERROR(piFile);

    nRetCode = piFile->Write(pcsBuff, (unsigned long)uBuffSize);
    KGLOG_PROCESS_ERROR(nRetCode == uBuffSize);

Exit0:
    SAFE_RELEASE(piFile);
    return 0;
}
コード例 #9
0
ファイル: item.cpp プロジェクト: 1suming/pap2
int KItemNull::Init(Lua_State *pLua, int nTableIndex)
{
	int nResult  = false;
	int nRetCode = false;

    char  szTip[KD_NORMAL_BUFFER_SIZE];
    char  szFilePath[MAX_PATH];
    int   nDisableScaled     = false;
    int   nShowTipType       = 0;
    int   nTipRichText       = 0;
    int   nLockShowAndHide   = false;
    DWORD dwEventID          = 0;
    int   nAutoSize          = false;

    static char szDecodedText[ITEM_MAX_DECODE_TEXT_LEN];

    KLuaTableField aParamTable[] = 
    {
        KLUA_TABLE_FIELD("name",         emVAR_TYPE_STRING, "",    &m_szItemName,     _countof(m_szItemName)),
        KLUA_TABLE_FIELD("PosType",      emVAR_TYPE_INT,    0,     &m_dwPosType,      0),
        KLUA_TABLE_FIELD("left",         emVAR_TYPE_FLOAT,  0,     &m_fRelX,          0),
        KLUA_TABLE_FIELD("top",          emVAR_TYPE_FLOAT,  0,     &m_fRelY,          0),
        KLUA_TABLE_FIELD("width",        emVAR_TYPE_FLOAT,  0,     &m_fWidth,         0),
        KLUA_TABLE_FIELD("height",       emVAR_TYPE_FLOAT,  0,     &m_fHeight,        0),
        KLUA_TABLE_FIELD("AutoSize",     emVAR_TYPE_FLOAT,  false, &nAutoSize,        0),
        KLUA_TABLE_FIELD("alpha",        emVAR_TYPE_INT,    255,   &m_dwAlpha,        0),
        KLUA_TABLE_FIELD("tip",          emVAR_TYPE_STRING, "",    &szTip,            _countof(szTip)),
        KLUA_TABLE_FIELD("ShowTipType",  emVAR_TYPE_INT,    0,     &nShowTipType,     0),
        KLUA_TABLE_FIELD("TipRichText",  emVAR_TYPE_INT,    0,     &nTipRichText,     0),
        KLUA_TABLE_FIELD("DisableScale", emVAR_TYPE_INT,    false, &nDisableScaled,   0),
        KLUA_TABLE_FIELD("lock",         emVAR_TYPE_INT,    false, &nLockShowAndHide, 0),
        KLUA_TABLE_FIELD("script",       emVAR_TYPE_STRING, "",    szDecodedText,     _countof(szDecodedText)),
        KLUA_TABLE_FIELD("event",        emVAR_TYPE_INT,    0,     &m_dwEvent,        0),
        KLUA_TABLE_FIELD("AreaFile",     emVAR_TYPE_STRING, "",    szFilePath,        _countof(szFilePath)),
    };                                                                                                  
                                                                                                        
    KGLOG_PROCESS_ERROR(pLua);                                                                          
                                                                                                        
    for (int i = 0; i < _countof(aParamTable); i++)                                                     
    {                                                                                                   
        nRetCode = g_LuaGetTableField(pLua, nTableIndex, &aParamTable[i]);                              
        KGLOG_PROCESS_ERROR(nRetCode);                                                                  
    }           

    m_emObjType = em_OBJ_TYPE_ITEM;      // 指定类型
                                                                                                        
    if (szTip[0])                                                                                       
    {                                                                                                   
        int nTipIndex = g_pUI->m_GlobalStrValuableMgr.GetIndexAt(szTip);                    
        m_nTipIndex = KTipCenter::GetSelf().Append(nTipIndex, nShowTipType, nTipRichText);
    }

    g_SetBitFlag(nDisableScaled, ITEM_NEVER_SCALED, m_dwStyle);
    g_SetBitFlag(nLockShowAndHide, LOCK_SHOW_AND_HIDE, m_dwStyle);
    if (nLockShowAndHide)
        Hide();

    // TODO:tongxuehu m_fUserData ?

//     if (szDecodedText[0])
//     {
//         nRetCode = KUiComponentsDecoder::GetSelf().SetDecodedScript(ATL::CA2W(szDecodedText, KGUI_CODE_PAGE));
//         KGLOG_PROCESS_ERROR(nRetCode);
//     }

// TODO:tongxuehu
//     if (ItemNullData.pEventOwner)    
//     {
//         ItemNullData.pEventOwner->UpdateDrawList();
//         if(ItemNullData.dwEventID)
//         {
//             m_dwEvent = ItemNullData.dwEventID;
//         }
//     }

    if (szFilePath[0])
    {
        FormatFilePath(szFilePath);
        m_nAreaIndex = g_AreaTester.GetID(szFilePath);
    }

    g_SetBitFlag(false, ITEM_DATA_FORMATED, m_dwStyle);

// Exit1:
	nResult = true;
Exit0:
	return nResult;
}