Skip to content

Commit fdf7ff3

Browse files
committed
Fix files outside datadirectory not being moved #162
- move any files in archives which are not in the "Higurashi_Ep0X" into the game directory, keeping the same folder structure as in the archive file
1 parent 903461c commit fdf7ff3

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

higurashiInstaller.py

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,22 +243,42 @@ def moveFilesIntoPlace(self):
243243
Moves files from the directory they were extracted to
244244
to the game data folder
245245
"""
246+
# On MacOS, the datadirectory has a different path than in the archive file:
247+
#
248+
# datadirectory in archive file : "Higurashi_Ep0X"
249+
# datadirectory on Linux/Windows: "Higurashi_Ep0X"
250+
# datadirectory on Macos: "Contents/Resources/Data"
251+
#
252+
# To account for this, we rename the "Higurashi_Ep0X" folder to "Contents/Resources/Data" below
253+
# (self.dataDirectory should equal "Contents/Resources/Data" on MacOS)
246254
self._moveDirectoryIntoPlace(
247255
fromDir = os.path.join(self.extractDir, self.info.subModConfig.dataName),
248-
toDir = self.dataDirectory
256+
toDir = self.dataDirectory,
257+
log = True,
249258
)
259+
250260
if common.Globals.IS_WINDOWS:
251261
exePath = self.info.subModConfig.dataName[:-5] + ".exe"
252262
self._moveFileIntoPlace(
253263
fromPath = os.path.join(self.extractDir, exePath),
254264
toPath = os.path.join(self.directory, exePath),
265+
log=True,
255266
)
256267
elif common.Globals.IS_MAC:
257268
self._moveFileIntoPlace(
258269
fromPath = os.path.join(self.extractDir, "Contents/Resources/PlayerIcon.icns"),
259-
toPath = os.path.join(self.directory, "Contents/Resources/PlayerIcon.icns")
270+
toPath = os.path.join(self.directory, "Contents/Resources/PlayerIcon.icns"),
271+
log = True,
260272
)
261273

274+
# If any files still remain, just move them directly into the game directory,
275+
# keeping the same folder structure as inside the archive
276+
self._moveDirectoryIntoPlace(
277+
fromDir = self.extractDir,
278+
toDir = self.directory,
279+
log = True,
280+
)
281+
262282
def _applyLanguageSpecificSharedAssets(self, folderToApply):
263283
"""Helper function which applies language specific assets.
264284
Returns False if there was an error during the proccess.
@@ -322,11 +342,14 @@ def applyLanguagePatchFixesIfNecessary(self):
322342
'this error so we can fix it:\n\n'
323343
'"Invalid Language Specific Asset files found: {}"'.format(invalidUIFileList))
324344

325-
def _moveDirectoryIntoPlace(self, fromDir, toDir):
326-
# type: (str, str) -> None
345+
def _moveDirectoryIntoPlace(self, fromDir, toDir, log=False):
346+
# type: (str, str, Optional[bool]) -> None
327347
"""
328348
Recursive function that does the actual moving for `moveFilesIntoPlace`
329349
"""
350+
if log:
351+
print("_moveDirectoryIntoPlace: '{}' -> '{}'".format(fromDir, toDir))
352+
330353
for file in os.listdir(fromDir):
331354
src = path.join(fromDir, file)
332355
target = path.join(toDir, file)
@@ -340,11 +363,14 @@ def _moveDirectoryIntoPlace(self, fromDir, toDir):
340363
shutil.move(src, target)
341364
forceRemoveDir(fromDir)
342365

343-
def _moveFileIntoPlace(self, fromPath, toPath):
344-
# type: (str, str) -> None
366+
def _moveFileIntoPlace(self, fromPath, toPath, log=False):
367+
# type: (str, str, Optional[bool]) -> None
345368
"""
346369
Moves a single file from `fromPath` to `toPath`
347370
"""
371+
if log:
372+
print("_moveFileIntoPlace: '{}' -> '{}'".format(fromPath, toPath))
373+
348374
if path.exists(fromPath):
349375
if path.exists(toPath):
350376
forceRemove(toPath)

0 commit comments

Comments
 (0)