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


C++ CFileIO::Write方法代码示例

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


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

示例1: InitNodeID

// The method is called after the database is created or loaded.
// This guarantees that the directory is there.
// The file with an identifier could be read or created safely.
// Returns: true if everything is fine.
void CNetScheduleServer::InitNodeID(const string &  db_path)
{
    CFile   node_id_file(CFile::MakePath(
                            CDirEntry::AddTrailingPathSeparator(db_path),
                            "NODE_ID"));

    if (node_id_file.Exists()) {
        // File exists, read the ID from it
        CFileIO     f;
        char        buffer[64];

        f.Open(node_id_file.GetPath(), CFileIO_Base::eOpen,
                                       CFileIO_Base::eRead);
        size_t      n = f.Read(buffer, sizeof(buffer));

        m_NodeID = string(buffer, n);
        NStr::TruncateSpacesInPlace(m_NodeID, NStr::eTrunc_End);
        f.Close();
    } else {
        // No file, need to be created
        m_NodeID = "n" + x_GenerateGUID();

        CFileIO     f;
        f.Open(node_id_file.GetPath(), CFileIO_Base::eCreate,
                                       CFileIO_Base::eReadWrite);
        f.Write(m_NodeID.data(), m_NodeID.size());
        f.Close();
    }
}
开发者ID:jackgopack4,项目名称:pico-blast,代码行数:33,代码来源:ns_server.cpp

示例2: CreateFile

void CTest::CreateFile(const string& path, size_t offset, size_t size)
{
    CFileIO fio;
    fio.Open(path, CFileIO::eCreate, CFileIO::eReadWrite);
    assert((offset + size) <= m_BufLen);
    size_t n = fio.Write(m_Buf + offset, size);
    assert(n == size);
    fio.Close();
    assert(CFile(path).Exists());
}
开发者ID:svn2github,项目名称:ncbi_tk,代码行数:10,代码来源:test_compress_archive.cpp

示例3: Write

void CLog::Write( const std::string sLog )
{
	printf( sLog.c_str() );

	// ログ出力モードになっているかをチェック
	if( !IsWrite() )	return;
	// 今日の日付でファイルを作成する
	struct tm *date;
	time_t now;
	time(&now);
	date = localtime(&now);

	// ファイル名
	char buffa[_MAX_PATH];
	SHGetSpecialFolderPath(NULL, buffa, CSIDL_DESKTOPDIRECTORY, FALSE);
	sprintf_s( buffa, _MAX_PATH, "%s\\%04d%02d%02d.log", buffa, date->tm_year + 1900, date->tm_mon + 1 , date->tm_mday );

	std::ostringstream os;
	os << std::setw(2) << date->tm_hour << ":" << std::setw(2) << date->tm_min << "\t" << sLog;

	CFileIO io;
	io.Write( os.str(), std::ios::app, buffa );
}
开发者ID:i-Seiza,项目名称:SoftwareController,代码行数:23,代码来源:Log.cpp


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