mirror of
https://github.com/Escartem/AnimeWwise.git
synced 2026-06-13 05:31:03 +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):
|
def __init__(self):
|
||||||
self.files = {}
|
self.files = {}
|
||||||
|
|
||||||
def load_file(self, path):
|
def load_file(self, path, name):
|
||||||
filename = os.path.basename(path)
|
|
||||||
with open(path, "r+b") as f:
|
with open(path, "r+b") as f:
|
||||||
mmap_object = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
|
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):
|
def unload_file(self, name):
|
||||||
self.files[os.path.basename(name)].close()
|
self.files[name].close()
|
||||||
|
|
||||||
def read_at(self, file, offset, size):
|
def read_at(self, file, offset, size):
|
||||||
mmap_object = self.files[os.path.basename(file)]
|
mmap_object = self.files[file]
|
||||||
mmap_object.seek(offset)
|
mmap_object.seek(offset)
|
||||||
data = mmap_object.read(size)
|
data = mmap_object.read(size)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def free_mem(self):
|
def free_mem(self):
|
||||||
for file in list(self.files.keys()):
|
for file in list(self.files.keys()):
|
||||||
self.files[os.path.basename(file)].close()
|
self.files[file].close()
|
||||||
self.files.clear()
|
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")]
|
files = [os.path.join(self.folders["input"], f) for f in os.listdir(self.folders["input"]) if f.endswith(".pck")]
|
||||||
elif self.loadType == "file":
|
elif self.loadType == "file":
|
||||||
path = QFileDialog.getOpenFileName(self, "Select .pck File", "", "PCK Files (*.pck)", options=QFileDialog.Options())
|
path = QFileDialog.getOpenFileName(self, "Select .pck File", "", "PCK Files (*.pck)", options=QFileDialog.Options())
|
||||||
|
self.folders["input"] = os.path.dirname(path[0])
|
||||||
files = [path[0]]
|
files = [path[0]]
|
||||||
|
|
||||||
if len(files) == 0 or files[0] == "":
|
if len(files) == 0 or files[0] == "":
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ class WwiseExtract:
|
|||||||
if os.path.isfile(hdiff_path):
|
if os.path.isfile(hdiff_path):
|
||||||
load_path = 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
|
# extract every file from this one
|
||||||
for file in [file for file in files if file["source"] == source]:
|
for file in [file for file in files if file["source"] == source]:
|
||||||
|
|||||||
Reference in New Issue
Block a user