当前位置: 首页>>代码示例>>C++>>正文


C++ RBuf8::Assign方法代码示例

本文整理汇总了C++中RBuf8::Assign方法的典型用法代码示例。如果您正苦于以下问题:C++ RBuf8::Assign方法的具体用法?C++ RBuf8::Assign怎么用?C++ RBuf8::Assign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RBuf8的用法示例。


在下文中一共展示了RBuf8::Assign方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: printMessage

void SymbianLog::printMessage(const char* level, const char* msg, PLATFORM_VA_LIST argList) 
{
    iSemaphore.Wait();
    
    StringBuffer currentTime = createCurrentTime(true);
    
    TInt err = file.Open(fsSession, iLogName, EFileWrite|EFileShareAny);
    TInt pos = 0;
    
    if (err == KErrNotFound) 
    {
        // First time: file does not exist. Create it.
        err = file.Create(fsSession, iLogName, EFileWrite|EFileShareAny);
        if (err != KErrNone) {
            setErrorF(err, "SymbianLog: could not open log file (code %d)", err);
            goto finally;
        }
        StringBuffer header = createHeader();
        RBuf8 data;
        data.Assign(stringBufferToNewBuf8(header));
        file.Write(data);
        data.Close();
    }
    else 
    {
        err = file.Seek(ESeekEnd, pos);
        if (err != KErrNone) {
            setErrorF(err, "SymbianLog: seek error on log file (code %d)", err);
            goto finally;
        }
    }

    {
        // Write the data
        StringBuffer line, data;
        line.sprintf("%s -%s- %s", currentTime.c_str(), level, msg);
        data.vsprintf(line.c_str(), argList);
        data.append("\n");
        
        RBuf8 buf;
        buf.Assign(stringBufferToNewBuf8(data));
        file.Write(buf);
        buf.Close();
    }
    
finally:
    file.Close();
    // we need closed file to operate on it
    if ( LogSize() > SYMBIAN_LOG_SIZE ){
        // roll log file
        RollLogFile();
    }
    iSemaphore.Signal();
}
开发者ID:pohly,项目名称:funambol-cpp-client-api,代码行数:54,代码来源:Log.cpp

示例2: reset

void SymbianLog::reset(const char* title) 
{
    iSemaphore.Wait();
    
    TInt err = file.Replace(fsSession, iLogName, EFileWrite|EFileShareAny);
    if (err != KErrNone) {
        setErrorF(err, "SymbianLog: error resetting the log file (code %d)", err);
        return;
    }
    
    // Write the Header
    StringBuffer header = createHeader(title);
    RBuf8 buf;
    buf.Assign(stringBufferToNewBuf8(header));
    file.Write(buf);
    buf.Close();
    
    file.Close();
    iSemaphore.Signal();
}
开发者ID:pohly,项目名称:funambol-cpp-client-api,代码行数:20,代码来源:Log.cpp

示例3: RollLogFile

void SymbianLog::RollLogFile(void)
{
    CFileMan* fileMan = CFileMan::NewL(fsSession);
    CleanupStack::PushL(fileMan);
    //copy the current file into the roll file, file must be open
    TInt err = KErrNone;
    err = file.Open(fsSession, iLogName, EFileWrite|EFileShareAny);
    if (err != KErrNone) {
        setErrorF(err, "SymbianLog: could not open log file (code %d)", err);
    } else {
        err = fileMan->Copy(file,iRollLogName,CFileMan::EOverWrite);
    }
    if (err != KErrNone) {
        setErrorF(err, "SymbianLog: copy error on roll log file (code %d)", err);
    }
    file.Close();
    // reset the current file
    // we don't use reset() method because we don't want 
    // nested semaphores
    err = KErrNone;
    err = file.Replace(fsSession, iLogName, EFileWrite|EFileShareAny);
    if (err != KErrNone) {
        setErrorF(err, "SymbianLog: error resetting the log file (code %d)", err);
        return;
    }
    // Write the Header
    StringBuffer header = createHeader();
    RBuf8 buf;
    buf.Assign(stringBufferToNewBuf8(header));
    file.Write(buf);
    buf.Close();
    file.Close();
    
    CleanupStack::PopAndDestroy(fileMan);

}
开发者ID:pohly,项目名称:funambol-cpp-client-api,代码行数:36,代码来源:Log.cpp

示例4: logName

SymbianLog::SymbianLog(bool resetLog, const char* path, const char* name) 
{
    TInt err = KErrNone;
    
    const char* p = (path)? path : SYMBIAN_LOG_PATH;
    const char* n = (name)? name : SYMBIAN_LOG_NAME;
    
    // assign all the paths and names
    StringBuffer logName(p);
    logName += n;
    iLogName.Assign(charToNewBuf(logName.c_str()));
    
    StringBuffer rollName(logName);
    rollName += ".0";
    iRollLogName.Assign(charToNewBuf(rollName.c_str()));
    
    StringBuffer pathSb(p);
    iLogPathName.Assign(charToNewBuf(pathSb.c_str()));
    
    StringBuffer nameSb(n);
    iLogFileName.Assign(charToNewBuf(nameSb.c_str()));
    
    // try open log
    err = iSemaphore.OpenGlobal(KLogSemaphoreName);

    if (err == KErrNotFound) {
        // Create a semaphore, to avoid accessing the FileSystem at
        // the same time by different threads.
        // The semaphore is global, so that it could be used also by
        // other processes that (in future) will use this Log.
        err = iSemaphore.CreateGlobal(KLogSemaphoreName, 1);
        if (err != KErrNone) {
            setError(ERR_SEMAPHORE_CREATION, ERR_SEMAPHORE_CREATION_MSG);
        }
    }

    iSemaphore.Wait();
    
    // Connect to the file server session.
    fsSession.Connect();
    err = fsSession.ShareAuto();
    if (err != KErrNone) {
        setErrorF(err, "SymbianLog error: unable to share RFs session (code %d)", err);
        return;
    }
    
    // ensure path exists!
    BaflUtils::EnsurePathExistsL(fsSession, iLogPathName);
    
    if (resetLog) {
        err = file.Replace(fsSession, iLogName, EFileWrite|EFileShareAny);
        if (err != KErrNone) {
            setErrorF(err, "SymbianLog: could not open the log file '%ls'", iLogName.Ptr());
            return;
        }
        
        // Write the Header
        StringBuffer header = createHeader();
        RBuf8 data;
        data.Assign(stringBufferToNewBuf8(header));
        file.Write(data);
        data.Close();
        file.Close();
    }
    
    iSemaphore.Signal();
    return;
}
开发者ID:pohly,项目名称:funambol-cpp-client-api,代码行数:68,代码来源:Log.cpp


注:本文中的RBuf8::Assign方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。