Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix files outside datadirectory not being moved #162
Browse files Browse the repository at this point in the history
 - 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
drojf committed Aug 21, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 700cdf1 commit d6c46d6
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions higurashiInstaller.py
Original file line number Diff line number Diff line change
@@ -243,22 +243,42 @@ def moveFilesIntoPlace(self):
Moves files from the directory they were extracted to
to the game data folder
"""
# On MacOS, the datadirectory has a different path than in the archive file:
#
# datadirectory in archive file : "Higurashi_Ep0X"
# datadirectory on Linux/Windows: "Higurashi_Ep0X"
# datadirectory on Macos: "Contents/Resources/Data"
#
# To account for this, we rename the "Higurashi_Ep0X" folder to "Contents/Resources/Data" below
# (self.dataDirectory should equal "Contents/Resources/Data" on MacOS)
self._moveDirectoryIntoPlace(
fromDir = os.path.join(self.extractDir, self.info.subModConfig.dataName),
toDir = self.dataDirectory
toDir = self.dataDirectory,
log = True,
)

if common.Globals.IS_WINDOWS:
exePath = self.info.subModConfig.dataName[:-5] + ".exe"
self._moveFileIntoPlace(
fromPath = os.path.join(self.extractDir, exePath),
toPath = os.path.join(self.directory, exePath),
log=True,
)
elif common.Globals.IS_MAC:
self._moveFileIntoPlace(
fromPath = os.path.join(self.extractDir, "Contents/Resources/PlayerIcon.icns"),
toPath = os.path.join(self.directory, "Contents/Resources/PlayerIcon.icns")
toPath = os.path.join(self.directory, "Contents/Resources/PlayerIcon.icns"),
log = True,
)

# If any files still remain, just move them directly into the game directory,
# keeping the same folder structure as inside the archive
self._moveDirectoryIntoPlace(
fromDir = self.extractDir,
toDir = self.directory,
log = True,
)

def _applyLanguageSpecificSharedAssets(self, folderToApply):
"""Helper function which applies language specific assets.
Returns False if there was an error during the proccess.
@@ -322,11 +342,14 @@ def applyLanguagePatchFixesIfNecessary(self):
'this error so we can fix it:\n\n'
'"Invalid Language Specific Asset files found: {}"'.format(invalidUIFileList))

def _moveDirectoryIntoPlace(self, fromDir, toDir):
# type: (str, str) -> None
def _moveDirectoryIntoPlace(self, fromDir, toDir, log=False):
# type: (str, str, Optional[bool]) -> None
"""
Recursive function that does the actual moving for `moveFilesIntoPlace`
"""
if log:
print("_moveDirectoryIntoPlace: '{}' -> '{}'".format(fromDir, toDir))

for file in os.listdir(fromDir):
src = path.join(fromDir, file)
target = path.join(toDir, file)
@@ -340,11 +363,14 @@ def _moveDirectoryIntoPlace(self, fromDir, toDir):
shutil.move(src, target)
forceRemoveDir(fromDir)

def _moveFileIntoPlace(self, fromPath, toPath):
# type: (str, str) -> None
def _moveFileIntoPlace(self, fromPath, toPath, log=False):
# type: (str, str, Optional[bool]) -> None
"""
Moves a single file from `fromPath` to `toPath`
"""
if log:
print("_moveFileIntoPlace: '{}' -> '{}'".format(fromPath, toPath))

if path.exists(fromPath):
if path.exists(toPath):
forceRemove(toPath)

0 comments on commit d6c46d6

Please sign in to comment.