int fileListGetArchiveEntries(FileList *list, char *path, int sort) { int res; if (!uf) return -1; FileListEntry *entry = malloc(sizeof(FileListEntry)); strcpy(entry->name, DIR_UP); entry->name_length = strlen(entry->name); entry->is_folder = 1; entry->type = FILE_TYPE_UNKNOWN; fileListAddEntry(list, entry, sort); char *archive_path = path + archive_path_start; int name_length = strlen(archive_path); FileListEntry *archive_entry = archive_list.head; int i; for (i = 0; i < archive_list.length; i++) { if (archive_entry->name_length >= name_length && strncasecmp(archive_entry->name, archive_path, name_length) == 0) { // Needs a / at end char *p = strchr(archive_entry->name + name_length, '/'); // it's a sub-directory if it has got a slash if (p) *p = '\0'; char name[MAX_PATH_LENGTH]; strcpy(name, archive_entry->name + name_length); if (p) { addEndSlash(name); } if (strlen(name) > 0 && !fileListFindEntry(list, name)) { FileListEntry *entry = malloc(sizeof(FileListEntry)); strcpy(entry->name, archive_entry->name + name_length); if (p) { addEndSlash(entry->name); entry->is_folder = 1; entry->type = FILE_TYPE_UNKNOWN; list->folders++; } else { entry->is_folder = 0; entry->type = getFileType(entry->name); list->files++; } entry->name_length = strlen(entry->name); entry->size = archive_entry->size; entry->size2 = archive_entry->size2; memcpy(&entry->ctime, &archive_entry->ctime, sizeof(SceDateTime)); memcpy(&entry->mtime, &archive_entry->mtime, sizeof(SceDateTime)); memcpy(&entry->atime, &archive_entry->atime, sizeof(SceDateTime)); fileListAddEntry(list, entry, sort); } if (p) *p = '/'; } // Next archive_entry = archive_entry->next; } return 0; }
int delete_thread(SceSize args_size, DeleteArguments *args) { SceUID thid = -1; // Set progress to 0% sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, 0); sceKernelDelayThread(DIALOG_WAIT); // Needed to see the percentage FileListEntry *file_entry = fileListGetNthEntry(args->file_list, args->index); int count = 0; FileListEntry *head = NULL; FileListEntry *mark_entry_one = NULL; if (fileListFindEntry(args->mark_list, file_entry->name)) { // On marked entry count = args->mark_list->length; head = args->mark_list->head; } else { count = 1; mark_entry_one = malloc(sizeof(FileListEntry)); strcpy(mark_entry_one->name, file_entry->name); head = mark_entry_one; } char path[MAX_PATH_LENGTH]; FileListEntry *mark_entry = NULL; // Get paths info uint32_t folders = 0, files = 0; mark_entry = head; int i; for (i = 0; i < count; i++) { disableAutoSuspend(); snprintf(path, MAX_PATH_LENGTH, "%s%s", args->file_list->path, mark_entry->name); removeEndSlash(path); getPathInfo(path, NULL, &folders, &files); mark_entry = mark_entry->next; } // Update thread thid = createStartUpdateThread(folders + files); // Remove process uint32_t value = 0; mark_entry = head; for (i = 0; i < count; i++) { snprintf(path, MAX_PATH_LENGTH, "%s%s", args->file_list->path, mark_entry->name); removeEndSlash(path); int res = removePath(path, &value, folders + files, SetProgress); if (res < 0) { closeWaitDialog(); errorDialog(res); goto EXIT; } mark_entry = mark_entry->next; } // Set progress to 100% sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, 100); sceKernelDelayThread(COUNTUP_WAIT); // Close sceMsgDialogClose(); dialog_step = DIALOG_STEP_DELETED; EXIT: if (mark_entry_one) free(mark_entry_one); if (thid >= 0) sceKernelWaitThreadEnd(thid, NULL, NULL); return sceKernelExitDeleteThread(0); }