diff --git a/allocator.py b/allocator.py index 1d9f424..65dfddb 100644 --- a/allocator.py +++ b/allocator.py @@ -6,23 +6,22 @@ class Allocator: def __init__(self): self.files = {} - def load_file(self, path): - filename = os.path.basename(path) + def load_file(self, path, name): with open(path, "r+b") as f: mmap_object = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) - self.files[filename] = mmap_object + self.files[name] = mmap_object def unload_file(self, name): - self.files[os.path.basename(name)].close() + self.files[name].close() def read_at(self, file, offset, size): - mmap_object = self.files[os.path.basename(file)] + mmap_object = self.files[file] mmap_object.seek(offset) data = mmap_object.read(size) return data def free_mem(self): for file in list(self.files.keys()): - self.files[os.path.basename(file)].close() + self.files[file].close() self.files.clear() diff --git a/app.py b/app.py index 158305f..3e2f56f 100644 --- a/app.py +++ b/app.py @@ -255,6 +255,7 @@ class AnimeWwise(QMainWindow): files = [os.path.join(self.folders["input"], f) for f in os.listdir(self.folders["input"]) if f.endswith(".pck")] elif self.loadType == "file": path = QFileDialog.getOpenFileName(self, "Select .pck File", "", "PCK Files (*.pck)", options=QFileDialog.Options()) + self.folders["input"] = os.path.dirname(path[0]) files = [path[0]] if len(files) == 0 or files[0] == "": diff --git a/extract.py b/extract.py index 6e8c551..d9aa31a 100644 --- a/extract.py +++ b/extract.py @@ -293,7 +293,7 @@ class WwiseExtract: if os.path.isfile(hdiff_path): load_path = hdiff_path - self.allocator.load_file(load_path) + self.allocator.load_file(load_path, source) # extract every file from this one for file in [file for file in files if file["source"] == source]: