| 56 | } |
| 57 | |
| 58 | int refreshNeeded(const char *app_path, const char* content_type) |
| 59 | { |
| 60 | char sfo_path[MAX_PATH_LENGTH]; |
| 61 | char appmeta_path[MAX_PATH_LENGTH]; |
| 62 | char appmeta_param[MAX_PATH_LENGTH]; |
| 63 | int mounted_appmeta; |
| 64 | |
| 65 | // Read param.sfo |
| 66 | snprintf(sfo_path, MAX_PATH_LENGTH, "%s/sce_sys/param.sfo", app_path); |
| 67 | void *sfo_buffer = NULL; |
| 68 | int sfo_size = allocateReadFile(sfo_path, &sfo_buffer); |
| 69 | if (sfo_size < 0) |
| 70 | return sfo_size; |
| 71 | |
| 72 | // Get title and content ids |
| 73 | char titleid[12], contentid[50], appver[8]; |
| 74 | getSfoString(sfo_buffer, "TITLE_ID", titleid, sizeof(titleid)); |
| 75 | getSfoString(sfo_buffer, "CONTENT_ID", contentid, sizeof(contentid)); |
| 76 | getSfoString(sfo_buffer, "APP_VER", appver, sizeof(appver)); |
| 77 | |
| 78 | // Free sfo buffer |
| 79 | free(sfo_buffer); |
| 80 | |
| 81 | // Check if app or dlc exists |
| 82 | if (((strcmp(content_type, "app") == 0)||(strcmp(content_type, "dlc") == 0))&&(checkAppExist(titleid))) { |
| 83 | char rif_name[48]; |
| 84 | |
| 85 | uint64_t aid; |
| 86 | sceRegMgrGetKeyBin("/CONFIG/NP", "account_id", &aid, sizeof(uint64_t)); |
| 87 | |
| 88 | // Check if bounded rif file exits |
| 89 | _sceNpDrmGetRifName(rif_name, 0, aid); |
| 90 | if (strcmp(content_type, "app") == 0) |
| 91 | snprintf(sfo_path, MAX_PATH_LENGTH, "ux0:license/app/%s/%s", titleid, rif_name); |
| 92 | else if (strcmp(content_type, "dlc") == 0) |
| 93 | snprintf(sfo_path, MAX_PATH_LENGTH, "ux0:license/addcont/%s/%s/%s", titleid, &contentid[20], rif_name); |
| 94 | if (checkFileExist(sfo_path)) |
| 95 | return 0; |
| 96 | |
| 97 | // Check if fixed rif file exits |
| 98 | _sceNpDrmGetFixedRifName(rif_name, 0, 0); |
| 99 | if (strcmp(content_type, "app") == 0) |
| 100 | snprintf(sfo_path, MAX_PATH_LENGTH, "ux0:license/app/%s/%s", titleid, rif_name); |
| 101 | else if (strcmp(content_type, "dlc") == 0) |
| 102 | snprintf(sfo_path, MAX_PATH_LENGTH, "ux0:license/addcont/%s/%s/%s", titleid, &contentid[20], rif_name); |
| 103 | if (checkFileExist(sfo_path)) |
| 104 | return 0; |
| 105 | } |
| 106 | |
| 107 | // Check if patch for installed app exists |
| 108 | else if (strcmp(content_type, "patch") == 0) { |
| 109 | if (!checkAppExist(titleid)) |
| 110 | return 0; |
| 111 | if (checkFileExist(sfo_path)) { |
| 112 | snprintf(appmeta_path, MAX_PATH_LENGTH, "ux0:appmeta/%s", titleid); |
| 113 | pfsUmount(); |
| 114 | if(pfsMount(appmeta_path)<0) |
| 115 | return 0; |
no test coverage detected