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

Function exportMedia

io_process.c:421–493  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

419}
420
421static int exportMedia(char *path, uint32_t *songs, uint32_t *videos, uint32_t *pictures, FileProcessParam *process_param) {
422 static char buf[64 * 1024];
423 char out[MAX_PATH_LENGTH];
424
425 SceIoStat stat;
426 memset(&stat, 0, sizeof(SceIoStat));
427
428 int res = sceIoGetstat(path, &stat);
429 if (res < 0)
430 return res;
431
432 int type = getFileType(path);
433 if (type == FILE_TYPE_BMP || type == FILE_TYPE_JPEG || type == FILE_TYPE_PNG) {
434 PhotoExportParam param;
435 memset(&param, 0, sizeof(PhotoExportParam));
436 param.version = 0x03150021;
437 res = scePhotoExportFromFile(path, &param, buf, process_param ? process_param->cancelHandler : NULL,
438 NULL, out, MAX_PATH_LENGTH);
439 if (res < 0)
440 return (res == 0x80101A0B) ? 0 : res;
441
442 if (process_param) {
443 if (process_param->value)
444 (*process_param->value) += stat.st_size;
445
446 if (process_param->SetProgress)
447 process_param->SetProgress(process_param->value ? *process_param->value : 0, process_param->max);
448 }
449
450 (*pictures)++;
451 } else if (type == FILE_TYPE_MP3) {
452 uint32_t value = 0;
453
454 uint32_t args[3];
455 args[0] = (uint32_t)stat.st_size;
456 args[1] = (uint32_t)&value;
457 args[2] = (uint32_t)process_param;
458
459 MusicExportParam param;
460 memset(&param, 0, sizeof(MusicExportParam));
461 res = sceMusicExportFromFile(path, &param, buf, process_param ? process_param->cancelHandler : NULL,
462 musicExportProgress, &args, out, MAX_PATH_LENGTH);
463 if (res < 0)
464 return (res == 0x8010530A) ? 0 : res;
465
466 (*songs)++;
467 } else if (type == FILE_TYPE_MP4) {
468 VideoExportInputParam in_param;
469 memset(&in_param, 0, sizeof(VideoExportInputParam));
470 strncpy(in_param.path, path, MAX_PATH_LENGTH-1);
471 in_param.path[MAX_PATH_LENGTH-1] = '\0';
472
473 VideoExportOutputParam out_param;
474 memset(&out_param, 0, sizeof(VideoExportOutputParam));
475
476 res = sceVideoExportFromFile(&in_param, 1, buf, process_param ? process_param->cancelHandler : NULL,
477 NULL, NULL, 0, &out_param);
478 if (res < 0)

Callers 1

exportPathFunction · 0.85

Calls 1

getFileTypeFunction · 0.85

Tested by

no test coverage detected