mirror of
https://github.com/Escartem/AnimeWwise.git
synced 2026-06-04 23:40:25 +08:00
fix file loading
This commit is contained in:
11
allocator.py
11
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()
|
||||
|
||||
1
app.py
1
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] == "":
|
||||
|
||||
@@ -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]:
|
||||
|
||||
Reference in New Issue
Block a user