| 174 | } |
| 175 | |
| 176 | int copy_thread(SceSize args_size, CopyArguments *args) { |
| 177 | SceUID thid = -1; |
| 178 | |
| 179 | // Lock power timers |
| 180 | powerLock(); |
| 181 | |
| 182 | // Set progress to 0% |
| 183 | sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, 0); |
| 184 | sceKernelDelayThread(DIALOG_WAIT); // Needed to see the percentage |
| 185 | |
| 186 | char path[MAX_PATH_LENGTH], src_path[MAX_PATH_LENGTH], dst_path[MAX_PATH_LENGTH]; |
| 187 | FileListEntry *copy_entry = NULL; |
| 188 | |
| 189 | // Check if src and dst are in the same partition when moving |
| 190 | int diff_partition = 0; |
| 191 | |
| 192 | if (args->copy_mode == COPY_MODE_MOVE) { |
| 193 | char *p = strchr(args->file_list->path, ':'); |
| 194 | char *q = strchr(args->copy_list->path, ':'); |
| 195 | if (p && q) { |
| 196 | *p = '\0'; |
| 197 | *q = '\0'; |
| 198 | |
| 199 | if (strcasecmp(args->file_list->path, args->copy_list->path) != 0) { |
| 200 | diff_partition = 1; |
| 201 | } |
| 202 | |
| 203 | *q = ':'; |
| 204 | *p = ':'; |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | if (args->copy_mode == COPY_MODE_MOVE && !diff_partition) { // Move |
| 209 | // Update thread |
| 210 | thid = createStartUpdateThread(args->copy_list->length, 0); |
| 211 | |
| 212 | copy_entry = args->copy_list->head; |
| 213 | |
| 214 | int i; |
| 215 | for (i = 0; i < args->copy_list->length; i++) { |
| 216 | snprintf(src_path, MAX_PATH_LENGTH, "%s%s", args->copy_list->path, copy_entry->name); |
| 217 | snprintf(dst_path, MAX_PATH_LENGTH, "%s%s", args->file_list->path, copy_entry->name); |
| 218 | |
| 219 | int res = movePath(src_path, dst_path, MOVE_INTEGRATE | MOVE_REPLACE, NULL); |
| 220 | if (res < 0) { |
| 221 | closeWaitDialog(); |
| 222 | errorDialog(res); |
| 223 | goto EXIT; |
| 224 | } |
| 225 | |
| 226 | SetProgress(i + 1, args->copy_list->length); |
| 227 | |
| 228 | if (cancelHandler()) { |
| 229 | closeWaitDialog(); |
| 230 | setDialogStep(DIALOG_STEP_CANCELED); |
| 231 | goto EXIT; |
| 232 | } |
| 233 |
nothing calls this directly
no test coverage detected