本文整理汇总了C++中FILE::ends方法的典型用法代码示例。如果您正苦于以下问题:C++ FILE::ends方法的具体用法?C++ FILE::ends怎么用?C++ FILE::ends使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FILE
的用法示例。
在下文中一共展示了FILE::ends方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: proc_unix2dos
int proc_unix2dos(const wstrings_c & pars)
{
if (pars.size() < 3) return 0;
wstr_c pts = pars.get(1); fix_path(pts, FNO_SIMPLIFY);
if (!dir_present(pts))
{
Print(FOREGROUND_RED, "path-to-files not found: %s", pts.cstr()); return 0;
}
wstrings_c exts(pars.get(2), '.');
if (exts.size() == 0)
{
Print(FOREGROUND_RED, "no exts defined");
return 0;
}
wstrings_c lines;
wstrings_c sfiles;
fill_dirs_and_files(pts, sfiles, lines);
for (const wstr_c & f : sfiles)
{
bool ok = false;
for (const wstr_c & e : exts)
if (f.ends(ts::wstr_c(CONSTWSTR(".")).append(e)) || fn_get_name_with_ext(f).equals(e))
{
ok = true;
break;
}
if (ok)
{
buf_c b;
b.load_from_disk_file(f);
for (int i = b.size() - 1; i >= 0; --i)
{
if (b.data()[i] == '\r')
b.cut(i, 1);
}
for (int i = b.size() - 1; i >= 0; --i)
{
if (b.data()[i] == '\n')
*b.expand(i, 1) = '\r';
}
b.save_to_file(f);
}
}
return 0;
}
示例2: proc_lochange
int proc_lochange(const wstrings_c & pars)
{
if (pars.size() < 3) return 0;
wstr_c pts = pars.get(1); fix_path(pts, FNO_SIMPLIFY);
if (!dir_present(pts))
{
Print(FOREGROUND_RED, "path-to-source not found: %s", pts.cstr()); return 0;
}
wstr_c ptl = pars.get(2); fix_path(ptl, FNO_SIMPLIFY);
if (!dir_present(ptl))
{
Print(FOREGROUND_RED, "path-to-loc not found: %s", ptl.cstr()); return 0;
}
wstr_c tolocale = CONSTWSTR("en");
if (pars.size() >= 4)
tolocale = pars.get(3);
wstrings_c lines;
wstrings_c sfiles;
fill_dirs_and_files(pts, sfiles, lines);
hashmap_t<int, wstr_c> localehash;
wstrings_c localelines;
parse_text_file(fn_join(ptl, tolocale) + CONSTWSTR(".labels.lng"), localelines, true);
for (const wstr_c &ls : localelines)
{
token<wchar> t(ls, '=');
pwstr_c stag = *t;
int tag = t->as_int(-1);
++t;
wstr_c l(*t); l.trim();
if (tag > 0)
localehash[tag] = l;
}
for (const wstr_c & f : sfiles)
{
if (f.ends(CONSTWSTR(".h")) || f.ends(CONSTWSTR(".cpp")))
{
parse_text_file(f, lines);
bool cmnt = false;
bool changed = false;
int cnt = lines.size();
for (int ln = 0; ln < cnt; ++ln)
{
wstr_c & l = lines.get(ln);
int workindex = 0;
wstr_c txt;
int tag, left, rite;
while (findTTT(l, txt, tag, cmnt, left, rite, workindex))
{
if (tag >= 0)
{
wstr_c txtto = localehash[tag];
l.replace( left, rite-left, CONSTWSTR("TTT(\"") + txtto + CONSTWSTR("\",") + wmake(tag) + CONSTWSTR(")") );
changed = true;
}
}
}
if (changed)
savelines(f, lines);
}
}
return 0;
}