| 71 | } |
| 72 | |
| 73 | bool 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 | |
| 106 | void *CGb2Utf8::run(void) |
| 107 | { |
nothing calls this directly
no test coverage detected