本文整理汇总了C++中CFileWriter类的典型用法代码示例。如果您正苦于以下问题:C++ CFileWriter类的具体用法?C++ CFileWriter怎么用?C++ CFileWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CFileWriter类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//---------------------------------------------------------------------------
// @function:
// CIOUtils::Dump
//
// @doc:
// Dump given string to output file
//
//---------------------------------------------------------------------------
void
CIOUtils::Dump
(
CHAR *file_name,
CHAR *sz
)
{
CAutoSuspendAbort asa;
const ULONG ulWrPerms = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
GPOS_TRY
{
CFileWriter fw;
fw.Open(file_name, ulWrPerms);
const BYTE *pb = reinterpret_cast<const BYTE*>(sz);
ULONG_PTR ulpLength = (ULONG_PTR) clib::Strlen(sz);
fw.Write(pb, ulpLength);
fw.Close();
}
GPOS_CATCH_EX(ex)
{
// ignore exceptions during dumping
GPOS_RESET_EX;
}
GPOS_CATCH_END;
// reset time slice
#ifdef GPOS_DEBUG
CWorker::Self()->ResetTimeSlice();
#endif // GPOS_DEBUG
}
示例2: INFO_PRINTF1
/*
* TestUnlockResourcesL: Test that the CloseOutputPlugin method ???
*
* Expected Verdict: PASS/FAIL/PANIC
*
* Prerequisites:
*
* Description: Retrieve and print some data from an external ini data file
*
*/
void CFile0Step::TestUnlockResourcesL()
{
CFileWriter* fileWriter = CFileWriter::NewL();
INFO_PRINTF1(_L("Invoking CFileWriter::CloseOutputPlugin(). CloseOutputPlugin() is supposed to do nothing."));
fileWriter->CloseOutputPlugin();
ASSERT_TRUE(ETrue);
delete fileWriter;
}
示例3: CFileWriter
Holly::IWriter* CHolly::CreateFileWriter( const std::string& strFileName )
{
CFileWriter* pWriter = new CFileWriter();
if ( !pWriter->Open( strFileName ) )
{
pWriter->Delete();
return NULL;
}
return pWriter;
}
示例4: DumpQueryToFile
Datum
DumpQueryToFile(PG_FUNCTION_ARGS)
{
char *szSql = textToString(PG_GETARG_TEXT_P(0));
char *szFilename = textToString(PG_GETARG_TEXT_P(1));
size_t iQueryStringLen = -1;
char *pcQuery = getQueryBinary(szSql, &iQueryStringLen);
CFileWriter fw;
fw.Open(szFilename, S_IRUSR | S_IWUSR);
fw.Write(reinterpret_cast<const BYTE*>(&iQueryStringLen), sizeof(iQueryStringLen));
fw.Write(reinterpret_cast<const BYTE*>(pcQuery), iQueryStringLen);
fw.Close();
PG_RETURN_UINT32( (ULONG) iQueryStringLen);
}
示例5: DumpPlanToFile
Datum
DumpPlanToFile(PG_FUNCTION_ARGS)
{
char *szSql = text_to_cstring(PG_GETARG_TEXT_P(0));
char *szFilename = text_to_cstring(PG_GETARG_TEXT_P(1));
size_t iBinaryLen = -1;
char *pcBinary = getPlannedStmtBinary(szSql, &iBinaryLen);
CFileWriter fw;
fw.Open(szFilename, S_IRUSR | S_IWUSR);
fw.Write(reinterpret_cast<const BYTE*>(&iBinaryLen), sizeof(iBinaryLen));
fw.Write(reinterpret_cast<const BYTE*>(pcBinary), iBinaryLen);
fw.Close();
PG_RETURN_UINT32((ULONG) iBinaryLen);
}
示例6: parseSQL
static int translateQueryToFile
(
char *szSqlText,
char *szFilename
)
{
Query *pquery = parseSQL(szSqlText);
Assert(pquery);
char *szXmlString = COptTasks::SzDXL(pquery);
int iLen = (int) gpos::clib::UlStrLen(szXmlString);
CFileWriter fw;
fw.Open(szFilename, S_IRUSR | S_IWUSR);
fw.Write(reinterpret_cast<const BYTE*>(szXmlString), iLen + 1);
fw.Close();
return iLen;
}
示例7: DumpPlanToDXLFile
Datum
DumpPlanToDXLFile(PG_FUNCTION_ARGS)
{
char *szSql = textToString(PG_GETARG_TEXT_P(0));
char *szFilename = textToString(PG_GETARG_TEXT_P(1));
PlannedStmt *pplstmt = planQuery(szSql);
Assert(pplstmt);
char *szXmlString = COptTasks::SzDXL(pplstmt);
int iLen = (int) gpos::clib::UlStrLen(szXmlString);
CFileWriter fw;
fw.Open(szFilename, S_IRUSR | S_IWUSR);
fw.Write(reinterpret_cast<const BYTE*>(szXmlString), iLen + 1);
fw.Close();
PG_RETURN_INT32(iLen);
}
示例8: wxGetCwd
void CShowOneDescriptionDlg::OnButton(wxCommandEvent& event)
{
if (event.GetId()==wxID_OK)
{
int err;
wxString CurrentDir = wxGetCwd();
if (!m_descr)
return;
wxFileDialog dialog(GetParent(),
wxT("Save current text"),
wxT(""),
wxT(""),
wxT(SZ_ALL_FILES),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
err = dialog.ShowModal();
wxSetWorkingDirectory(CurrentDir);
if (wxID_OK == err)
{
CFileWriter F;
if (F.Open(dialog.GetPath().mb_str()))
{
F.WriteBuf(m_descr, strlen(m_descr));
F.Close();
}
else
wxMessageBox(wxT("Can not open file"));
}
}
else if (event.GetId()==wxID_CANCEL)
{
StoreSize();
EndModal(wxID_CANCEL);
}
}
示例9: Tokenize
void Tokenize (SDoc &p_soDoc)
{
int iFnRes;
CFileWriter coFileWriter;
iFnRes = coFileWriter.Init ();
if (iFnRes)
return;
iFnRes = coFileWriter.CreateOutputFile ("out.wbxml");
if (iFnRes)
return;
/* формируем версию */
p_soDoc.m_strBinHedr.append ((unsigned char*)&p_soDoc.m_soHdr.m_soVersion, sizeof (p_soDoc.m_soHdr.m_soVersion));
/* формируем public_id */
p_soDoc.m_strBinHedr.append ((unsigned char*)&p_soDoc.m_soHdr.m_soPublicId, sizeof (p_soDoc.m_soHdr.m_soPublicId));
/* формируем charset */
p_soDoc.m_strBinHedr.append ((unsigned char*)&p_soDoc.m_soHdr.m_soCharSet, sizeof (p_soDoc.m_soHdr.m_soCharSet));
/* формируем body */
u_int8 ui8CodePage = 0;
TokenizeBody (p_soDoc.m_psoBodyFirst, p_soDoc.m_strBinBody, p_soDoc);
/* формируем strtbl */
std::string strStrTbl;
for (unsigned int i = 0; i < p_soDoc.m_soHdr.m_vectStrTbl.size (); i++) {
strStrTbl.append (p_soDoc.m_soHdr.m_vectStrTbl[i].data (), p_soDoc.m_soHdr.m_vectStrTbl[i].length () + 1);
}
std::basic_string<mb_u_int32> strStrLen;
LongLong_toub_u_int32 (strStrTbl.length (), strStrLen);
p_soDoc.m_strBinHedr.append ((unsigned char*)strStrLen.data (), strStrLen.length());
if (strStrTbl.length ())
p_soDoc.m_strBinHedr.append ((unsigned char*)strStrTbl.data (), strStrTbl.length ());
coFileWriter.WriteData (p_soDoc.m_strBinHedr.data (), p_soDoc.m_strBinHedr.size ());
coFileWriter.WriteData (p_soDoc.m_strBinBody.data (), p_soDoc.m_strBinBody.size ());
coFileWriter.Finalise ();
}
示例10: S
void CShowDescriptionListDlg::SaveAs()
{
int err, i;
CBaseObject * pObj;
CStr S(128);
wxString CurrentDir = wxGetCwd();
wxFileDialog dialog(GetParent(),
wxT("Save current text"),
wxT(""),
wxT(""),
wxT(SZ_ALL_FILES),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
err = dialog.ShowModal();
wxSetWorkingDirectory(CurrentDir);
if (wxID_OK == err)
{
CFileWriter F;
if (F.Open(dialog.GetPath().mb_str()))
{
for (i=0; i<m_pItems->Count(); i++)
{
pObj = (CBaseObject*)m_pItems->At(i);
S = pObj->Description;
S.TrimRight(TRIM_ALL);
S << EOL_FILE;
F.WriteBuf(S.GetData(), S.GetLength());
}
F.Close();
}
else
wxMessageBox(wxT("Can not open file"));
}
}
示例11: INFO_PRINTF1
//.........这里部分代码省略.........
else
{
blockSize = impl->BlockSize();
}
HBufC8* iv = NULL;
if ((TUid(operationMode) == KOperationModeCBCUid) || (TUid(operationMode) == KOperationModeCTRUid))
{
// block size is in bits so to allocate the correct number of bytes divide by 8
// iv is left on the cleanup stack for the duration of the test and deleted in a conditional at the end of the outer block.
// If this conditional block changes, take care to update the condition for deleting this allocated IV, near the end of this function.
iv = HBufC8::NewLC(blockSize/8);
// blocksize is in bits so to allocate the correct number of 8 byte chunks divide by 64
for(TInt i = 0 ; i <blockSize/64 ; i++)
{
iv->Des().Append(_L8("12345678"));
}
TRAP_LOG(err,impl->SetIvL(iv->Des()));
}
// convert to bytesize
blockSize/=8;
blockSize += iOffset;
//read from src file
CFileReader* srcData = CFileReader::NewLC(srcPath,blockSize);
// first step is to read from the src file one block
// at a time, encrypt that block and then write
// the encrypted block out to a temporary file.
CFileWriter* encryptedDataWriter = CFileWriter::NewLC(TPtrC(KTempEncryptedFilePath));
TInt numBlocks = srcData->NumBlocks();
INFO_PRINTF1(_L("Starting Incremental Encryption..."));
for(TInt i = 1 ; i <= numBlocks ; i++)
{
TRAP_LOG(err,srcData->ReadBlockL());
//Create buffer for encrypted data
TInt maxOutputLength = impl->MaxFinalOutputLength(TPtrC8(*srcData).Length());
HBufC8* encrypted = HBufC8::NewLC(maxOutputLength);
TPtr8 encryptedPtr = encrypted->Des();
if(i == numBlocks)
{
TRAP(err,impl->ProcessFinalL(*srcData, encryptedPtr));
if(err != KErrNone)
{
ERR_PRINTF3(_L("*** ERROR:%d - ProcessFinalL() Block=%d ***"),err,i);
User::Leave(err);
}
}
else
{
TRAP(err,impl->ProcessL(*srcData, encryptedPtr));
if(err != KErrNone)
{
ERR_PRINTF3(_L("*** ERROR:%d - ProcessL() Block=%d ***"),err,i);
User::Leave(err);
示例12: while
RCType
TraceGen::generate(J9TDFOptions *options, const char *currentTDFFile)
{
RCType rc = RC_FAILED;
unsigned int groupCount = 0;
J9TDFGroup *groups = NULL;
J9TDFFile *tdf = NULL;
FileReader reader;
TDFParser parser;
Path *current = _visitedFile;
char *realPath = NULL;
/**
* User might specify multiple scan roots for example -root src,src/omr
* To avoid processing trace files multiple times keep the record of processed files.
* To handle relative paths omrfile_realpath is used to resolve canonicalized absolute pathname.
*/
if (NULL == (realPath = Port::omrfile_realpath(currentTDFFile))) {
FileUtils::printError("Failed to resolve full path to file: %s\n", currentTDFFile);
goto done;
}
while (NULL != current) {
if (0 == strcmp(current->path, realPath)) {
break;
}
current = current->next;
}
if (NULL == current) {
Path *tmp = (Path *) Port::omrmem_calloc(1, sizeof(Path));
tmp->path = realPath;
tmp->next = _visitedFile;
_visitedFile = tmp;
} else if (options->debugOutput) {
FileUtils::printError("File %s was already processed\n", realPath);
goto done;
}
printf("Processing tdf file %s\n", currentTDFFile);
rc = reader.init(currentTDFFile);
if (RC_OK != rc) {
FileUtils::printError("Failed to read from file: %s\n", currentTDFFile);
goto done;
}
parser.init(&reader, options->treatWarningAsError);
tdf = parser.parse();
if (NULL == tdf) {
rc = RC_FAILED;
goto done;
}
tdf->fileName = strdup(currentTDFFile);
if (NULL == tdf->fileName) {
eprintf("Failed to allocate memory");
rc = RC_FAILED;
goto done;
}
groups = calculateGroups(tdf, &groupCount);
if (NULL == groups) {
FileUtils::printError("Failed to calculate tracepoint groups");
rc = RC_FAILED;
goto done;
}
TraceHeaderWriter hfw;
DATFileWriter dfw;
CFileWriter cfw;
rc = hfw.writeOutputFiles(options, tdf);
if (RC_OK != rc) {
FileUtils::printError("Failed to generate header file for %s\n", currentTDFFile);
goto done;
}
rc = dfw.writeOutputFiles(options, tdf);
if (RC_OK != rc) {
FileUtils::printError("Failed to generate DAT file for %s\n", currentTDFFile);
goto done;
}
if (options->generateCFiles) {
rc = cfw.writeOutputFiles(options, tdf, groups, groupCount);
if (RC_OK != rc) {
FileUtils::printError("Failed to generate C file for %s\n", currentTDFFile);
goto done;
}
}
done:
if (NULL != tdf) {
Port::omrmem_free((void **)&tdf->fileName);
Port::omrmem_free((void **)&tdf->header.datfilename);
Port::omrmem_free((void **)&tdf->header.executable);
Port::omrmem_free((void **)&tdf->header.submodules);
J9TDFTracepoint *tp = tdf->tracepoints;
while (NULL != tp) {
//.........这里部分代码省略.........
示例13: _mkdir
//================================================================================================================
CreateGameDirectory::CreateGameDirectory(GameDirectory3D* gd)
{
_mkdir(gd->GAME_FOLDER.c_str());
_mkdir(gd->m_required_textures.c_str());
_mkdir(gd->m_menu_sprites_path.c_str());
_mkdir(gd->m_hud_path.c_str());
_mkdir(gd->m_scripts_path.c_str());
_mkdir(gd->m_music_path.c_str());
_mkdir(gd->m_materials_path.c_str());
_mkdir(gd->m_heightmaps_path.c_str());
_mkdir(gd->m_template_poly_path.c_str());
_mkdir(gd->m_models_path.c_str());
_mkdir(gd->m_textures_path.c_str());
_mkdir(gd->m_xml_path.c_str());
//_mkdir(gd->m_xml_menu_path.c_str());
//_mkdir(gd->m_xml_hud_path.c_str());
_mkdir(gd->m_xml_maps_path.c_str());
CFileWriter fileWriter;
fileWriter.Open(gd->m_game_ini_path);
fileWriter.Write("[GAME]\n");
fileWriter.Write("\n");
fileWriter.Write(";Game can either be Topdown or Platformer, 3D for 3D game\n");
fileWriter.Write("GameType=3D\n");
fileWriter.Close();
CFileWriter fileMainMenuWriter;
fileMainMenuWriter.Open(gd->m_xml_main_menu_path);
fileMainMenuWriter.Close();
CFileWriter fileInGameMenuWriter;
fileInGameMenuWriter.Open(gd->m_xml_ingame_menu_path);
fileInGameMenuWriter.Close();
CFileWriter fileHUDWriter;
fileHUDWriter.Open(gd->m_xml_hud_path);
fileHUDWriter.Close();
CopyFolder("RequiredTextures", gd->m_required_textures);
CopyFolder("RequiredScripts", gd->m_scripts_path);
CopyFolder("TemplatePolys", gd->m_template_poly_path);
}