void FileDir::_OsCreate( const FileDir& dirName ) { #ifdef _WIN32 CreateDirectory( removeEndSlash().toString().c_str(), NULL ); #else ::mkdir( dirName.toString().c_str(), S_IRWXU|S_IRWXG|S_IRWXO ); #endif }
void FileDir::_OsCreate( const FileDir& dirName ) { #ifdef OC3_PLATFORM_WIN CreateDirectory( removeEndSlash().toString().c_str(), NULL ); #elif defined(OC3_PLATFORM_UNIX) ::mkdir( dirName.toString().c_str(), S_IRWXU|S_IRWXG|S_IRWXO ); #endif }
Directory Directory::up() const { if( toString().empty() ) return Directory(); Path pathToAny = removeEndSlash(); std::string::size_type index = pathToAny.toString().find_last_of( "/" ); if( index != std::string::npos ) { return Path( pathToAny.toString().substr( 0, index ) ); } _CAESARIA_DEBUG_BREAK_IF( !exist() ); return Directory(); }
FilePath FilePath::getUpDir() const { if( !_d->path.size() ) return ""; FilePath pathToAny = removeEndSlash(); std::string::size_type index = pathToAny._d->path.find_last_of( "/" ); if( index != std::string::npos ) { return FilePath( pathToAny._d->path.substr( 0, index ) ); } _OC3_DEBUG_BREAK_IF( !isExist() ); return ""; }
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); }
int join_thread(SceSize args_size, JoinArguments *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 SceUID fd = -1; void *buf = NULL; FileListEntry *file_entry = fileListGetNthEntry(args->file_list, args->index); char path[MAX_PATH_LENGTH]; snprintf(path, MAX_PATH_LENGTH, "%s%s", args->file_list->path, file_entry->name); removeEndSlash(path); // Get file size char size_path[MAX_PATH_LENGTH]; snprintf(size_path, MAX_PATH_LENGTH, "%s/%s", path, SPLIT_SIZE_NAME); uint32_t size = 0; int res = ReadFile(size_path, &size, sizeof(uint32_t)); if (res < 0) { closeWaitDialog(); errorDialog(res); goto EXIT; } // Update thread thid = createStartUpdateThread((uint32_t)size); // Join process char dst_path[MAX_PATH_LENGTH]; strcpy(dst_path, path); char *p = strrchr(dst_path, '.'); if (p) *p = '\0'; fd = sceIoOpen(dst_path, SCE_O_WRONLY | SCE_O_CREAT | SCE_O_TRUNC, 0777); if (fd < 0) { closeWaitDialog(); errorDialog(fd); goto EXIT; } buf = malloc(SPLIT_PART_SIZE); uint32_t seek = 0; while (seek < size) { int part_num = seek / SPLIT_PART_SIZE; int folder_num = part_num / SPLIT_MAX_FILES; int file_num = part_num % SPLIT_MAX_FILES; char src_path[MAX_PATH_LENGTH]; snprintf(src_path, MAX_PATH_LENGTH, "%s/%04d/%04d", path, folder_num, file_num); int read = ReadFile(src_path, buf, SPLIT_PART_SIZE); if (read < 0) { closeWaitDialog(); errorDialog(read); goto EXIT; } int written = sceIoWrite(fd, buf, read); if (written < 0) { closeWaitDialog(); errorDialog(written); goto EXIT; } seek += read; SetProgress(seek, size); } // Set progress to 100% sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, 100); sceKernelDelayThread(COUNTUP_WAIT); // Close sceMsgDialogClose(); dialog_step = DIALOG_STEP_JOINED; EXIT: if (buf) free(buf); if (fd >= 0) sceIoClose(fd); if (thid >= 0) sceKernelWaitThreadEnd(thid, NULL, NULL); return sceKernelExitDeleteThread(0); }
int copy_thread(SceSize args_size, CopyArguments *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 char src_path[MAX_PATH_LENGTH], dst_path[MAX_PATH_LENGTH]; FileListEntry *copy_entry = NULL; if (args->copy_mode == COPY_MODE_MOVE) { // Move // Update thread thid = createStartUpdateThread(args->copy_list->length); copy_entry = args->copy_list->head; int i; for (i = 0; i < args->copy_list->length; i++) { snprintf(src_path, MAX_PATH_LENGTH, "%s%s", args->copy_list->path, copy_entry->name); snprintf(dst_path, MAX_PATH_LENGTH, "%s%s", args->file_list->path, copy_entry->name); int res = sceIoRename(src_path, dst_path); // TODO: if (res == SCE_ERROR_ERRNO_EEXIST) if folder if (res < 0) { closeWaitDialog(); errorDialog(res); goto EXIT; } SetProgress(i + 1, args->copy_list->length); copy_entry = copy_entry->next; } // Set progress to 100% sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, 100); sceKernelDelayThread(COUNTUP_WAIT); // Close sceMsgDialogClose(); dialog_step = DIALOG_STEP_MOVED; } else { // Copy if (args->copy_mode == COPY_MODE_EXTRACT) archiveOpen(args->archive_path); // Get src paths info uint32_t size = 0, folders = 0, files = 0; copy_entry = args->copy_list->head; int i; for (i = 0; i < args->copy_list->length; i++) { disableAutoSuspend(); snprintf(src_path, MAX_PATH_LENGTH, "%s%s", args->copy_list->path, copy_entry->name); if (args->copy_mode == COPY_MODE_EXTRACT) { addEndSlash(src_path); getArchivePathInfo(src_path, &size, &folders, &files); } else { removeEndSlash(src_path); getPathInfo(src_path, &size, &folders, &files); } copy_entry = copy_entry->next; } // Update thread thid = createStartUpdateThread(size + folders); // Copy process uint32_t value = 0; copy_entry = args->copy_list->head; for (i = 0; i < args->copy_list->length; i++) { snprintf(src_path, MAX_PATH_LENGTH, "%s%s", args->copy_list->path, copy_entry->name); snprintf(dst_path, MAX_PATH_LENGTH, "%s%s", args->file_list->path, copy_entry->name); if (args->copy_mode == COPY_MODE_EXTRACT) { addEndSlash(src_path); addEndSlash(dst_path); int res = extractArchivePath(src_path, dst_path, &value, size + folders, SetProgress); if (res < 0) { closeWaitDialog(); errorDialog(res); goto EXIT; } } else { removeEndSlash(src_path); removeEndSlash(dst_path); int res = copyPath(src_path, dst_path, &value, size + folders, SetProgress); if (res < 0) { closeWaitDialog(); errorDialog(res); goto EXIT; } } copy_entry = copy_entry->next; } // Set progress to 100% sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, 100); sceKernelDelayThread(COUNTUP_WAIT); // Close sceMsgDialogClose(); dialog_step = DIALOG_STEP_COPIED; } EXIT: if (thid >= 0) sceKernelWaitThreadEnd(thid, NULL, NULL); return sceKernelExitDeleteThread(0); }