| 214 | } |
| 215 | |
| 216 | error_code cellVideoExportFromFileWithCopy(vm::cptr<char> srcHddDir, vm::cptr<char> srcHddFile, vm::ptr<CellVideoExportSetParam> param, vm::ptr<CellVideoExportUtilFinishCallback> funcFinish, vm::ptr<void> userdata) |
| 217 | { |
| 218 | cellVideoExport.todo("cellVideoExportFromFileWithCopy(srcHddDir=%s, srcHddFile=%s, param=*0x%x, funcFinish=*0x%x, userdata=*0x%x)", srcHddDir, srcHddFile, param, funcFinish, userdata); |
| 219 | |
| 220 | if (!param || !funcFinish || !srcHddDir || !srcHddDir[0] || !srcHddFile || !srcHddFile[0]) |
| 221 | { |
| 222 | return CELL_VIDEO_EXPORT_UTIL_ERROR_PARAM; |
| 223 | } |
| 224 | |
| 225 | // TODO: check param members ? |
| 226 | |
| 227 | cellVideoExport.notice("cellVideoExportFromFileWithCopy: param: title=%s, game_title=%s, game_comment=%s, editable=%d", param->title, param->game_title, param->game_comment, param->editable); |
| 228 | |
| 229 | const std::string file_path = fmt::format("%s/%s", srcHddDir.get_ptr(), srcHddFile.get_ptr()); |
| 230 | |
| 231 | if (!check_movie_path(file_path)) |
| 232 | { |
| 233 | return {CELL_VIDEO_EXPORT_UTIL_ERROR_PARAM, file_path}; |
| 234 | } |
| 235 | |
| 236 | std::string filename; |
| 237 | |
| 238 | if (srcHddFile) |
| 239 | { |
| 240 | fmt::append(filename, "%s", srcHddFile.get_ptr()); |
| 241 | } |
| 242 | |
| 243 | if (filename.empty()) |
| 244 | { |
| 245 | return {CELL_VIDEO_EXPORT_UTIL_ERROR_PARAM, "filename empty"}; |
| 246 | } |
| 247 | |
| 248 | sysutil_register_cb([=](ppu_thread& ppu) -> s32 |
| 249 | { |
| 250 | auto& vexp = g_fxo->get<video_export>(); |
| 251 | vexp.progress = 0; // 0% |
| 252 | |
| 253 | const std::string src_path = vfs::get(file_path); |
| 254 | const std::string dst_path = get_available_movie_path(filename); |
| 255 | |
| 256 | cellVideoExport.notice("Copying file from '%s' to '%s'", file_path, dst_path); |
| 257 | |
| 258 | if (!fs::create_path(fs::get_parent_dir(dst_path)) || !fs::copy_file(src_path, dst_path, false)) |
| 259 | { |
| 260 | // TODO: find out which error is used |
| 261 | cellVideoExport.error("Failed to copy file from '%s' to '%s' (%s)", src_path, dst_path, fs::g_tls_error); |
| 262 | funcFinish(ppu, CELL_VIDEO_EXPORT_UTIL_ERROR_MOVE, userdata); |
| 263 | return CELL_OK; |
| 264 | } |
| 265 | |
| 266 | // TODO: write metadata file sometime in the far future |
| 267 | // const std::string metadata_file = dst_path + ".vmd"; |
| 268 | |
| 269 | // TODO: track progress during file copy |
| 270 | |
| 271 | vexp.progress = 0xFFFF; // 100% |
| 272 | |
| 273 | funcFinish(ppu, CELL_OK, userdata); |
nothing calls this directly
no test coverage detected