MCPcopy Create free account
hub / github.com/acl-dev/acl / TransformFile

Method TransformFile

app/jencode/Gb2Utf8.cpp:73–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73bool CGb2Utf8::TransformFile(const char *pFrom, const char *pTo)
74{
75 acl::string sBuf;
76 if (!acl::ifstream::load(pFrom, sBuf)) {
77 logger_error("load from %s error %s", pFrom, acl::last_serror());
78 return false;
79 }
80
81 acl::charset_conv conv;
82 acl::string tBuf;
83 if (!conv.convert(m_fromCharset.GetString(), m_toCharset.GetString(),
84 sBuf.c_str(), sBuf.size(), &tBuf)) {
85
86 logger_error("conver from %s to %s error: %s, file: %s",
87 m_fromCharset.GetString(), m_toCharset.GetString(),
88 conv.serror(), pFrom);
89 return false;
90 }
91
92 acl::ofstream fp;
93 if (!fp.open_write(pTo, true)) {
94 logger_error("open %s error %s", pTo, acl::last_serror());
95 return false;
96 }
97 if (fp.write(tBuf) != (int) tBuf.size()) {
98 logger_error("write to %s error %s", pTo, acl::last_serror());
99 } else {
100 logger("transer from %s to %s ok, file: %s",
101 m_fromCharset.GetString(), m_toCharset.GetString(), pTo);
102 }
103 return true;
104}
105
106void *CGb2Utf8::run(void)
107{

Callers

nothing calls this directly

Calls 7

convertMethod · 0.80
serrorMethod · 0.80
last_serrorFunction · 0.50
c_strMethod · 0.45
sizeMethod · 0.45
open_writeMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected