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


C++ FileOut::IsError方法代码示例

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


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

示例1: PosOverrunTest

void PosOverrunTest()
{
    String tmpfile = GetTempFileName("pos");
    FileOut fo;
    if(!fo.Open(tmpfile)) {
        Cout() << "PosOverrunTest: error creating file "  << tmpfile << "\n";
        return;
    }
    for(int i = 0; i < 0x10000; i++)
        fo.PutIW(i);
    int64 size = fo.GetSize();
    fo.Close();
    if(fo.IsError() || size != 0x20000) {
        Cout() << "PosOverrunTest generator error, file " << tmpfile << "\n";
        return;
    }
    FileIn fi;
    fi.SetBufferSize(4096);
    if(!fi.Open(tmpfile)) {
        Cout() << "PosOverrunTest: error reopening temporary file " << tmpfile << "\n";
        return;
    }
    for(int i = 0; i < 4096; i++)
        fi.Get();
    char buffer[32];
    fi.GetAll(buffer, 32);
    bool ok = true;
    for(int i = 0; i < 16; i++) {
        int strmval = PeekIW(buffer + 2 * i);
        int expect = 2048 + i;
        if(strmval != expect) {
            Cout() << "PosOverrunTest: " << FormatIntHex(expect, 4) << " expected, " << FormatIntHex(strmval, 4) << " found\n";
            ok = false;
        }
    }
    if(ok)
        Cout() << "PosOverrunTest: finished without errors\n";
}
开发者ID:kolyden,项目名称:mirror,代码行数:38,代码来源:Stream.cpp

示例2: Run


//.........这里部分代码省略.........
			for(int i = 0; i < columns.GetCount(); i++)
				if(columns.Get(i, 3)) {
					out.Add(i);
					String cname = cursor.GetColumnInfo(i).name;
					colstr << (i ? ", " : "") << cname;
					if(i) title << delim;
					title << cname;
				}
			if(out.IsEmpty()) {
				throw Exc(t_("No columns selected!"));
				continue;
			}
			String rowbegin, rowend;
			int fmt = ~format;
			FileSel fsel;
			String ext;
			switch(fmt) {
				case FMT_TEXT: {
					rowend = "";
					ext = ".txt";
					fsel.Type(t_("Text files (*.txt)"), "*.txt");
					break;
				}
				case FMT_SQL: {
					if(identity_insert)
						rowbegin << "set identity_insert " << out_table << " on ";
					rowbegin << "insert into " << out_table << "(" << colstr << ") values (";
					rowend = ");";
					ext = ".sql";
					fsel.Type(t_("SQL scripts (*.sql)"), "*.sql");
					break;
				}
			}
			fsel.AllFilesType().DefaultExt(ext.Mid(1));
			if(!IsNull(recent_file))
				fsel <<= ForceExt(recent_file, ext);
			if(!fsel.ExecuteSaveAs(t_("Save export as")))
				continue;
			recent_file = ~fsel;
			FileOut fo;
			if(!fo.Open(recent_file)) {
				Exclamation(NFormat(t_("Error creating file [* \1%s\1]."), recent_file));
				continue;
			}
			if(fmt == FMT_TEXT)
				fo.PutLine(title);
			Progress progress(t_("Exporting row %d"));
			while(cursor.Fetch()) {
				String script = rowbegin;
				for(int i = 0; i < out.GetCount(); i++) {
					Value v = cursor[out[i]];
					switch(fmt) {
						case FMT_TEXT: {
							if(i)
								script.Cat(delim);
							if(IsString(v) && quote) {
								String s = v;
								script << '\"';
								for(const char *p = s, *e = s.End(); p < e; p++)
									if(*p == '\"')
										script.Cat("\"\"");
									else
										script.Cat(*p);
								script << '\"';
							}
							else
								script << StdFormat(v);
							break;
						}
						case FMT_SQL: {
							if(i) script.Cat(", ");
//							script << SqlCompile(SQLD_ORACLE, SqlFormat(v));
							break;
						}
					}
				}
				script << rowend;
				fo.PutLine(script);
/*
				if(autocommit && --left <= 0) {
					fo.PutLine("commit;");
					left = autocommit;
				}
*/
				if(progress.StepCanceled()) {
					Exclamation(t_("Export aborted!"));
					return;
				}
			}
			fo.Close();
			if(fo.IsError())
				throw Exc(NFormat(t_("Error writing file %s."), recent_file));
			break;
		}
		catch(Exc e) {
			ShowExc(e);
		}

	cfg = StoreAsString(*this);
}
开发者ID:radtek,项目名称:lister,代码行数:101,代码来源:SqlObjectTree.cpp


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