MCPcopy Create free account
hub / github.com/RPCSX/rpcsx / cellVideoExportFromFile

Function cellVideoExportFromFile

ps3fw/cellVideoExport.cpp:280–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278}
279
280error_code cellVideoExportFromFile(vm::cptr<char> srcHddDir, vm::cptr<char> srcHddFile, vm::ptr<CellVideoExportSetParam> param, vm::ptr<CellVideoExportUtilFinishCallback> funcFinish, vm::ptr<void> userdata)
281{
282 cellVideoExport.todo("cellVideoExportFromFile(srcHddDir=%s, srcHddFile=%s, param=*0x%x, funcFinish=*0x%x, userdata=*0x%x)", srcHddDir, srcHddFile, param, funcFinish, userdata);
283
284 if (!param || !funcFinish || !srcHddDir || !srcHddDir[0] || !srcHddFile || !srcHddFile[0])
285 {
286 return CELL_VIDEO_EXPORT_UTIL_ERROR_PARAM;
287 }
288
289 // TODO: check param members ?
290
291 cellVideoExport.notice("cellVideoExportFromFile: param: title=%s, game_title=%s, game_comment=%s, editable=%d", param->title, param->game_title, param->game_comment, param->editable);
292
293 const std::string file_path = fmt::format("%s/%s", srcHddDir.get_ptr(), srcHddFile.get_ptr());
294
295 if (!check_movie_path(file_path))
296 {
297 return {CELL_VIDEO_EXPORT_UTIL_ERROR_PARAM, file_path};
298 }
299
300 std::string filename;
301
302 if (srcHddFile)
303 {
304 fmt::append(filename, "%s", srcHddFile.get_ptr());
305 }
306
307 if (filename.empty())
308 {
309 return {CELL_VIDEO_EXPORT_UTIL_ERROR_PARAM, "filename empty"};
310 }
311
312 sysutil_register_cb([=](ppu_thread& ppu) -> s32
313 {
314 auto& vexp = g_fxo->get<video_export>();
315 vexp.progress = 0; // 0%
316
317 const std::string src_path = vfs::get(file_path);
318 const std::string dst_path = get_available_movie_path(filename);
319
320 cellVideoExport.notice("Copying file from '%s' to '%s'", file_path, dst_path);
321
322 if (!fs::create_path(fs::get_parent_dir(dst_path)) || !fs::copy_file(src_path, dst_path, false))
323 {
324 // TODO: find out which error is used
325 cellVideoExport.error("Failed to copy file from '%s' to '%s' (%s)", src_path, dst_path, fs::g_tls_error);
326 funcFinish(ppu, CELL_VIDEO_EXPORT_UTIL_ERROR_MOVE, userdata);
327 return CELL_OK;
328 }
329
330 if (!file_path.starts_with("/dev_bdvd"sv))
331 {
332 cellVideoExport.notice("Removing file '%s'", src_path);
333
334 if (!fs::remove_file(src_path))
335 {
336 // TODO: find out if an error is used here
337 cellVideoExport.error("Failed to remove file '%s' (%s)", src_path, fs::g_tls_error);

Callers

nothing calls this directly

Calls 11

check_movie_pathFunction · 0.85
appendFunction · 0.85
sysutil_register_cbFunction · 0.85
getFunction · 0.85
get_available_movie_pathFunction · 0.85
create_pathFunction · 0.85
get_parent_dirFunction · 0.85
errorMethod · 0.80
formatEnum · 0.50
get_ptrMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected