void wrd_add_path(char *path, int pathlen) { if(pathlen == 0) pathlen = strlen(path); if(!wrd_add_path_one(path, pathlen)) return; if(current_file_info && get_archive_type(current_file_info->filename) != -1) { MBlockList buf; char *arc_path; int baselen; init_mblock(&buf); baselen = strrchr(current_file_info->filename, '#') - current_file_info->filename + 1; arc_path = new_segment(&buf, baselen + pathlen + 1); strncpy(arc_path, current_file_info->filename, baselen); strncpy(arc_path + baselen, path, pathlen); arc_path[baselen + pathlen] = '\0'; put_string_table(&path_list, arc_path, strlen(arc_path)); reuse_mblock(&buf); } }
struct timidity_file *wrd_open_file(char *filename) { StringTableNode *path; struct timidity_file *tf; if(get_archive_type(filename) != -1) return open_file(filename, 0, OF_SILENT); for(path = path_list.head; path; path = path->next){ if((tf = try_wrd_open_file(path->string, filename)) != NULL) return tf; } return try_wrd_open_file(CUR_DIR_PATH, filename); }
bool archive_impl::is_our_path(const char * path) { if (!g_is_unpack_path(path)) return false; const char * type = get_archive_type(); path += 9; while(*type) { if (*type!=*path) return false; type++; path++; } if (*path!='|') return false; return true; }
extern bool extract_archive_file(const char *archname, const char *archpath, const char *dest, t_copy_cb cb, t_copy_overwritecb ocb, void *data) { t_fs_filetype ft; SceUID fd; bool result = false; buffer *archdata = NULL; int buffer_cache; char *ptr; if (archname == NULL || archpath == NULL || dest == NULL) return false; ft = get_archive_type(archname); if (ft == fs_filetype_unknown) return false; if (ocb != NULL) { SceUID fd; fd = xrIoOpen(dest, PSP_O_RDONLY, 0777); if (fd >= 0) { if (!ocb(dest, data)) { xrIoClose(fd); return false; } xrIoClose(fd); } } dbg_printf(d, "extract_archive_file: %s %s %s, ft = %d", archname, archpath, dest, ft); fd = xrIoOpen(dest, PSP_O_CREAT | PSP_O_RDWR, 0777); if (fd < 0) return false; extract_archive_file_into_buffer(&archdata, archname, archpath, ft); if (archdata == NULL || archdata->ptr == NULL) goto exit; buffer_cache = archdata->used >= 1024 * 1024 ? 1024 * 1024 : archdata->used; ptr = archdata->ptr; while (buffer_cache > 0) { int bytes = xrIoWrite(fd, ptr, buffer_cache); if (bytes < 0) { goto exit; } buffer_cache = archdata->used - bytes >= 1024 * 1024 ? 1024 * 1024 : archdata->used - bytes; ptr += bytes; } result = true; exit: xrIoClose(fd); if (archdata != NULL) { buffer_free(archdata); } return result; }
void archive_impl::make_unpack_path(pfc::string_base & path,const char * archive,const char * file) {g_make_unpack_path(path,archive,file,get_archive_type());}