MCPcopy Create free account
hub / github.com/GDRETools/gdsdecomp / _add_files

Method _add_files

utility/pck_creator.cpp:281–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

279}
280
281Error PckCreator::_add_files(
282 const HashMap<String, String> &file_paths_to_pack) {
283 if (file_paths_to_pack.is_empty()) {
284 return OK;
285 }
286 uint64_t start_time = OS::get_singleton()->get_ticks_msec();
287 files_to_pck.resize(file_paths_to_pack.size());
288 Vector<String> keys;
289 keys.resize(file_paths_to_pack.size());
290 {
291 size_t i = 0;
292 for (auto &e : file_paths_to_pack) {
293 files_to_pck.write[i] = { e.value, e.key, 0, 0, encrypt, false, empty_md5 };
294 keys.write[i] = e.key;
295 i++;
296 }
297 }
298 Error err = OK;
299 err = TaskManager::get_singleton()->run_multithreaded_group_task(
300 this,
301 &PckCreator::_do_process_folder,
302 files_to_pck.ptrw(),
303 files_to_pck.size(),
304 &PckCreator::get_file_description,
305 "PckCreator::_do_process_folder",
306 "Getting file info...");
307 if (err == ERR_SKIP) {
308 return ERR_SKIP;
309 }
310 if (broken_cnt > 0) {
311 err = ERR_BUG;
312 for (int64_t i = 0; i < files_to_pck.size(); i++) {
313 if (files_to_pck[i].err != OK) {
314 String err_type;
315 if (files_to_pck[i].err == ERR_FILE_CANT_OPEN) {
316 err_type = "FileAccess error";
317 } else if (files_to_pck[i].err == ERR_CANT_CREATE) {
318 err_type = "FileCreate error";
319 } else if (files_to_pck[i].err == ERR_FILE_CANT_WRITE) {
320 err_type = "FileWrite error";
321 } else {
322 err_type = "Unknown error";
323 }
324 error_string += files_to_pck[i].src_path + "(" + err_type + ")\n";
325 }
326 }
327 }
328
329 if (error_string.length() > 0) {
330 print_error("At least one error was detected while adding files!\n" + error_string);
331 return err;
332 }
333 files_to_pck.resize(files_to_pck.size());
334 for (int64_t i = 0; i < files_to_pck.size(); i++) {
335 files_to_pck.write[i].ofs = offset;
336 uint64_t _size = files_to_pck[i].size;
337 if (encrypt) { // Add encryption overhead.
338 _size += get_encryption_padding(_size);

Callers

nothing calls this directly

Calls 6

get_encryption_paddingFunction · 0.85
_get_padFunction · 0.85
lengthMethod · 0.80
resizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected