MCPcopy Create free account
hub / github.com/TheOfficialFloW/VitaShell / extractPsarcPath

Function extractPsarcPath

psarc.c:427–490  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

425}
426
427int extractPsarcPath(const char *src_path, const char *dst_path, FileProcessParam *param) {
428 SceFiosDH dh = -1;
429 SceFiosBuffer buf = SCE_FIOS_BUFFER_INITIALIZER;
430 if (sceFiosDHOpenSync(NULL, &dh, src_path, buf) >= 0) {
431 int ret = sceIoMkdir(dst_path, 0777);
432 if (ret < 0 && ret != SCE_ERROR_ERRNO_EEXIST) {
433 sceFiosDHCloseSync(NULL, dh);
434 return ret;
435 }
436
437 if (param) {
438 if (param->value)
439 (*param->value) += DIRECTORY_SIZE;
440
441 if (param->SetProgress)
442 param->SetProgress(param->value ? *param->value : 0, param->max);
443
444 if (param->cancelHandler && param->cancelHandler()) {
445 sceFiosDHCloseSync(NULL, dh);
446 return 0;
447 }
448 }
449
450 int res = 0;
451
452 do {
453 SceFiosDirEntry dir;
454 memset(&dir, 0, sizeof(SceFiosDirEntry));
455
456 res = sceFiosDHReadSync(NULL, dh, &dir);
457 if (res >= 0) {
458 char *name = dir.fullPath + dir.offsetToName;
459
460 char *new_src_path = malloc(strlen(src_path) + strlen(name) + 2);
461 snprintf(new_src_path, MAX_PATH_LENGTH, "%s%s%s", src_path, hasEndSlash(src_path) ? "" : "/", name);
462
463 char *new_dst_path = malloc(strlen(dst_path) + strlen(name) + 2);
464 snprintf(new_dst_path, MAX_PATH_LENGTH, "%s%s%s", dst_path, hasEndSlash(dst_path) ? "" : "/", name);
465
466 int ret = 0;
467
468 if (dir.statFlags & 0x1) {
469 ret = extractPsarcPath(new_src_path, new_dst_path, param);
470 } else {
471 ret = extractPsarcFile(new_src_path, new_dst_path, param);
472 }
473
474 free(new_dst_path);
475 free(new_src_path);
476
477 if (ret <= 0) {
478 sceFiosDHCloseSync(NULL, dh);
479 return ret;
480 }
481 }
482 } while (res >= 0);
483
484 sceFiosDHCloseSync(NULL, dh);

Callers 1

extractArchivePathFunction · 0.85

Calls 2

hasEndSlashFunction · 0.85
extractPsarcFileFunction · 0.85

Tested by

no test coverage detected