@@ -389,23 +389,41 @@ void GameManager::InstallZipContents(ZipFileTask task) {
389
389
// Examine the URL to guess out what we're installing.
390
390
// TODO: Bad idea due to Android content api where we don't always get the filename.
391
391
if (urlExtension == " .cso" || urlExtension == " .iso" || urlExtension == " .chd" ) {
392
- // It's a raw ISO or CSO file. We just copy it to the destination.
393
- std::string shortFilename = task.url .GetFilename ();
394
- bool success = InstallRawISO (task.fileName , shortFilename, task.deleteAfter );
392
+ // It's a raw ISO or CSO file. We just copy it to the destination, which is the
393
+ // currently selected directory in the game browser. Note: This might not be a good option!
394
+ Path destPath = Path (g_Config.currentDirectory ) / task.url .GetFilename ();
395
+ if (!File::Exists (destPath)) {
396
+ // Fall back to the root of the memstick.
397
+ destPath = g_Config.memStickDirectory ;
398
+ }
399
+ g_OSD.SetProgressBar (" install" , di->T (" Installing..." ), 0 .0f , 0 .0f , 0 .0f , 0 .1f );
400
+
401
+ // TODO: To save disk space, we should probably attempt a move first, if deleteAfter is true.
402
+ // TODO: Update the progress bar continuously.
403
+ bool success = File::Copy (task.fileName , destPath);
404
+
395
405
if (!success) {
396
406
ERROR_LOG (Log::HLE, " Raw ISO install failed" );
397
407
// This shouldn't normally happen at all (only when putting ISOs in a store, which is not a normal use case), so skipping the translation string
398
408
SetInstallError (" Failed to install raw ISO" );
399
409
}
410
+ if (task.deleteAfter ) {
411
+ File::Delete (task.fileName );
412
+ }
413
+ g_OSD.RemoveProgressBar (" install" , success, 0 .5f );
414
+ installProgress_ = 1 .0f ;
415
+ InstallDone ();
400
416
return ;
401
417
}
402
418
403
419
int error = 0 ;
404
420
405
421
struct zip *z = ZipOpenPath (task.fileName );
406
422
if (!z) {
407
- g_OSD.RemoveProgressBar (" install" , false , 0 .5f );
423
+ g_OSD.RemoveProgressBar (" install" , false , 1 .5f );
408
424
SetInstallError (sy->T (" Unable to open zip file" ));
425
+ installProgress_ = 1 .0f ;
426
+ InstallDone ();
409
427
return ;
410
428
}
411
429
@@ -424,15 +442,17 @@ void GameManager::InstallZipContents(ZipFileTask task) {
424
442
{
425
443
Path pspGame = GetSysDirectory (DIRECTORY_GAME);
426
444
INFO_LOG (Log::HLE, " Installing '%s' into '%s'" , task.fileName .c_str (), pspGame.c_str ());
427
- // InstallZipContents contains code to close (and delete) z.
445
+ // InstallZipContents contains code to close z.
428
446
success = ExtractZipContents (z, pspGame, zipInfo, false );
429
447
break ;
430
448
}
431
449
case ZipFileContents::ISO_FILE:
432
- INFO_LOG (Log::HLE, " Installing '%s' into its containing directory" , task.fileName .c_str ());
450
+ {
451
+ INFO_LOG (Log::HLE, " Installing '%s' into '%s'" , task.fileName .c_str (), task.destination .c_str ());
433
452
// InstallZippedISO contains code to close z.
434
- success = InstallZippedISO (z, zipInfo.isoFileIndex , task.fileName , task. deleteAfter );
453
+ success = InstallZippedISO (z, zipInfo.isoFileIndex , task.destination );
435
454
break ;
455
+ }
436
456
case ZipFileContents::TEXTURE_PACK:
437
457
{
438
458
// InstallMemstickGame contains code to close z, and works for textures too.
@@ -468,10 +488,16 @@ void GameManager::InstallZipContents(ZipFileTask task) {
468
488
break ;
469
489
}
470
490
491
+ // Common functionality.
471
492
if (task.deleteAfter && success) {
472
493
File::Delete (task.fileName );
473
494
}
474
495
g_OSD.RemoveProgressBar (" install" , success, 0 .5f );
496
+ installProgress_ = 1 .0f ;
497
+ InstallDone ();
498
+ if (success) {
499
+ ResetInstallError ();
500
+ }
475
501
}
476
502
477
503
bool GameManager::DetectTexturePackDest (struct zip *z, int iniIndex, Path &dest) {
@@ -765,10 +791,6 @@ bool GameManager::ExtractZipContents(struct zip *z, const Path &dest, const ZipF
765
791
INFO_LOG (Log::HLE, " Unzipped %d files (%d bytes / %d)." , info.numFiles , (int )bytesCopied, (int )allBytes);
766
792
zip_close (z);
767
793
z = nullptr ;
768
- installProgress_ = 1 .0f ;
769
- InstallDone ();
770
- ResetInstallError ();
771
- g_OSD.RemoveProgressBar (" install" , true , 0 .5f );
772
794
return true ;
773
795
774
796
bail:
@@ -782,7 +804,6 @@ bool GameManager::ExtractZipContents(struct zip *z, const Path &dest, const ZipF
782
804
File::DeleteDir (iter);
783
805
}
784
806
SetInstallError (sy->T (" Storage full" ));
785
- g_OSD.RemoveProgressBar (" install" , false , 0 .5f );
786
807
return false ;
787
808
}
788
809
@@ -842,7 +863,7 @@ bool GameManager::InstallMemstickZip(struct zip *z, const Path &zipfile, const P
842
863
return true ;
843
864
}
844
865
845
- bool GameManager::InstallZippedISO (struct zip *z, int isoFileIndex, const Path &zipfile, bool deleteAfter ) {
866
+ bool GameManager::InstallZippedISO (struct zip *z, int isoFileIndex, const Path &destDir ) {
846
867
// Let's place the output file in the currently selected Games directory.
847
868
std::string fn = zip_get_name (z, isoFileIndex, 0 );
848
869
size_t nameOffset = fn.rfind (' /' );
@@ -866,7 +887,12 @@ bool GameManager::InstallZippedISO(struct zip *z, int isoFileIndex, const Path &
866
887
name = name.substr (2 );
867
888
}
868
889
869
- Path outputISOFilename = Path (g_Config.currentDirectory ) / name;
890
+ Path outputISOFilename = destDir;
891
+ if (outputISOFilename.empty ()) {
892
+ outputISOFilename = Path (g_Config.currentDirectory );
893
+ }
894
+ outputISOFilename = outputISOFilename / name;
895
+
870
896
size_t bytesCopied = 0 ;
871
897
bool success = false ;
872
898
auto di = GetI18NCategory (I18NCat::DIALOG);
@@ -876,10 +902,6 @@ bool GameManager::InstallZippedISO(struct zip *z, int isoFileIndex, const Path &
876
902
success = true ;
877
903
}
878
904
zip_close (z);
879
- if (success && deleteAfter) {
880
- File::Delete (zipfile);
881
- g_OSD.SetProgressBar (" install" , di->T (" Installing..." ), 0 .0f , 0 .0f , 0 .0f , 0 .1f );
882
- }
883
905
g_OSD.RemoveProgressBar (" install" , success, 0 .5f );
884
906
885
907
z = 0 ;
@@ -910,25 +932,6 @@ bool GameManager::UninstallGameOnThread(const std::string &name) {
910
932
return true ;
911
933
}
912
934
913
- bool GameManager::InstallRawISO (const Path &file, const std::string &originalName, bool deleteAfter) {
914
- Path destPath = Path (g_Config.currentDirectory ) / originalName;
915
- auto di = GetI18NCategory (I18NCat::DIALOG);
916
- g_OSD.SetProgressBar (" install" , di->T (" Installing..." ), 0 .0f , 0 .0f , 0 .0f , 0 .1f );
917
- // TODO: To save disk space, we should probably attempt a move first.
918
- if (File::Copy (file, destPath)) {
919
- if (deleteAfter) {
920
- File::Delete (file);
921
- }
922
- g_OSD.RemoveProgressBar (" install" , true , 0 .5f );
923
- } else {
924
- g_OSD.RemoveProgressBar (" install" , false , 0 .5f );
925
- }
926
- installProgress_ = 1 .0f ;
927
- InstallDone ();
928
- ResetInstallError ();
929
- return true ;
930
- }
931
-
932
935
void GameManager::ResetInstallError () {
933
936
if (!InstallInProgress ()) {
934
937
installError_.clear ();
0 commit comments