Beispiel #1
0
void RhoSettings::saveToFile(const char* szName)
{
    m_mapChangedValues.put(szName, getString(szName) );

    String strData;
    saveChangesToString(strData);

    CRhoFile oFile;
    oFile.open( (getConfFilePath()+CONF_CHANGES).c_str(), common::CRhoFile::OpenForWrite);
    oFile.write( strData.c_str(), strData.size() );
}
Beispiel #2
0
void RhoSettings::saveToFile(const char* szName, boolean bRemove/* = false*/)
{
    if ( !bRemove )
        m_mapChangedValues.put(szName, getString(szName) );
    else
        m_mapChangedValues.remove(szName);

    String strData;
    saveChangesToString(strData);

    CRhoFile oFile;
    oFile.open( (getAppConfUserFilePath()+CONF_CHANGES).c_str(), common::CRhoFile::OpenForWrite);
    oFile.write( strData.c_str(), strData.size() );
}
Beispiel #3
0
void CMainWindow::ShowLoadingPage()
{
	String fname = RHODESAPP().getLoadingPagePath();

	size_t pos = fname.find("file://");
	if (pos == 0 && pos != std::string::npos)
		fname.erase(0, 7);

    CRhoFile oFile;
    StringW strTextW;
    if ( oFile.open( fname.c_str(), common::CRhoFile::OpenReadOnly) )
        oFile.readStringW(strTextW);
    else
    {
		LOG(ERROR) + "failed to open loading page \"" + fname + "\"";
		strTextW = L"<html><head><title>Loading...</title></head><body><h1>Loading...</h1></body></html>";
    }

    m_pBrowserEng->NavigateToHtml(strTextW.c_str());
}
Beispiel #4
0
BSTR loadLoadingHtml()
{
	rho::String fname = RHODESAPP().getLoadingPagePath();

	size_t pos = fname.find("file://");
	if (pos == 0 && pos != std::string::npos)
		fname.erase(0, 7);

    CRhoFile oFile;
    StringW strTextW;
    if ( oFile.open( fname.c_str(), common::CRhoFile::OpenReadOnly) )
        oFile.readStringW(strTextW);
    else
    {
		LOG(ERROR) + "failed to open loading page \"" + fname + "\"";
		strTextW = L"<html><head><title>Loading...</title></head><body><h1>Loading...</h1></body></html>";
    }

    return SysAllocString(strTextW.c_str());
}
Beispiel #5
0
/*static*/ unsigned int CRhoFile::copyFile(const char* szSrcFile, const char* szDstFile) {
    
    CRhoFile src;
    CRhoFile dst;
    
    if (!src.open(szSrcFile, OpenReadOnly)) {
        return -1;
    }
    if (!dst.open(szDstFile, OpenForWrite)) {
        return -1;
    }
    
    unsigned int buf_size = 1 << 16;
    unsigned char* buf = new unsigned char[buf_size];
    
    unsigned int to_copy = src.size();
    
    while (to_copy > 0) {
        unsigned int portion_size = buf_size;
        if (to_copy < portion_size) {
            portion_size = to_copy;
        }
        src.readData(buf, 0, portion_size);
        dst.write(buf, portion_size);
        
        to_copy -= portion_size;
    }
    
    src.close();
    dst.flush();
    dst.close();
    
    delete buf;

    return 0;
}