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

Method transfer

app/iconv/charset_transfer.cpp:221–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

219}
220
221int charset_transfer::transfer(bool recursive /* = true */)
222{
223 if (check_params() == false)
224 return -1;
225
226 if (from_charset_.equal(to_charset_, false))
227 {
228 logger("to_charset_ is same as from_charset_(%s)",
229 from_charset_.c_str());
230 return 0;
231 }
232
233 acl::scan_dir scan;
234
235 if (scan.open(from_path_, recursive) == false)
236 {
237 logger_error("open dir %s error %s", from_path_.c_str(),
238 acl::last_serror());
239 return -1;
240 }
241
242 int count = 0;
243 const char* filename;
244
245 while ((filename = scan.next_file(false)) != NULL)
246 {
247 acl::string from_filepath, to_filepath, to_path;
248 if (!get_filepath(scan, filename, from_filepath,
249 to_filepath, to_path))
250 {
251 continue;
252 }
253
254 if (access(to_path.c_str(), 0) != 0
255 && (acl_make_dirs(to_path.c_str(), 0755) == -1))
256 {
257 logger_error("acl_make_dirs %s error %s",
258 to_path.c_str(), acl::last_serror());
259 continue;
260 }
261
262 if (transfer(from_filepath, to_filepath))
263 {
264 logger("transfer to %s OK!", to_filepath.c_str());
265 count++;
266 }
267 }
268
269 return count;
270}
271
272bool charset_transfer::transfer(const char* from_file, const char* to_file)
273{

Callers 1

mainFunction · 0.45

Calls 14

acl_make_dirsFunction · 0.85
save_toFunction · 0.85
equalMethod · 0.80
next_fileMethod · 0.80
convertMethod · 0.80
serrorMethod · 0.80
last_serrorFunction · 0.50
get_filepathFunction · 0.50
c_strMethod · 0.45
openMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected