Mord3rca/gamma-launcher

*nix case patch: Remaining Uppercase directories

Opened this issue · 13 comments

I got a little bit acquainted with python and wrote a recursive function that does what we need. The initial folder will not be renamed (The mod folder).

import os.path
import shutil

# renames all tree subdirectories to lowercase
def tree_lower_subdirectories(directory, modify_root = False):
    if not os.path.lexists(directory): return False

    if modify_root and any(map(str.isupper, os.path.basename(directory))):
        ps = os.path.split(directory)
        directory_lower=os.path.join(ps[0], ps[1].lower())
        if os.path.isdir(directory_lower): # already exists
            shutil.copytree(directory, directory_lower, dirs_exist_ok=True)
            shutil.rmtree(directory)
        else:
            os.rename(directory, directory_lower)
        directory = directory_lower

    for dir_ in os.listdir(directory):
        if os.path.isdir(os.path.join(directory, dir_)):
            tree_lower_subdirectories(
                os.path.join(directory, dir_),
                not modify_root and not modify_root or modify_root
            )

Originally posted by @Singustromo in #35 (comment)

I applied my function from the mentioned Issue on a finished installation and still noticed some Uppercase directories. As this probably leads to unpredictable behavior, it is worth a fix.

Attached is a file with the specific directories of the current GAMMA build which still had to be renamed.

Here's the list: dirs_modified.txt

I personally favor recursive functions for recursive tasks but I can understand the choice of not using one.

Hello,

NTFS case sensitivity is optional and disabled by default, this is why the case fix is only run for not *NT OS: https://github.com/Mord3rca/gamma-launcher/blob/master/launcher/commands/install.py#L99

Thanks for the answer. However, I think you misunderstand me.
The fix ran, as it should under GNU/Linux. It just leaves some directory names unchanged, which it should not do.
I assumed you'd know. Why would one report something that is not an issue on their os? )
On the other hand.. my title was a little bit misleading.

Yup, kinda read a bit too fast.

Bug confirmed, filter method is now updated. However, can you test it and check that S.T.A.L.K.E..R. is able to run correctly with this ?

This change does not cover the cases listed above.
There are still lower levels in the tree that have uppercase directories:
dirs_modified_new.txt

Have you done a full reinstall to get the new diff ? (wipe everything in mods/)

Greetings. Yes, of course.
Even if this wasn't the case. There would not have been any occurrences.
I always run my python script after I did a full re-install to check and correct this.

New modification, it should be good now.

sobkas commented

I have seen crashes at startup because of:
! c:/anomaly\appdata\shaders_cache\r4\ogse_sunshafts_mask.ps\20481111001100000000001000001003100101101000000
! error: ACES_LMT.h(18,10): error X1507: failed to open source file: 'ACES_LMTs\LMT_Contrast.h'

It turns out that there was lowercase ACES_LMTs folder that contained lmt_channel_mixer.h
Deleting this folder after moving file to ACES_LMTs fixed this problem

This implies to have a "smart launcher" which understand Stalker configuration files. Maybe it's safer to just keep things simple (and working)

sobkas commented

I think that only 100% sure way to make it work is to enable casefold in fs and enable it on directory basis with 'chattr +F'.
Then create sub-directories, extract and install stuff.

I agree on this. However, it requires a modification on the FS (tune2fs -o casefold <fs dev>) ... If this is the root partition, it can be hard to achieve.
Then: chattr +F <GAMMA PATH>/mods if the directory is empty should be enough.

May also be the case that the problem described by @sobkas is related to renaming the files themselves.
Could be that XRay is not that strict in this case?

I personally noticed the following problem with the current version of gamma-launcher: https://0x0.st/HWap.png

Because of that I removed the path-case-fix entirely and used this snippet afterwards - as told before:
#52 (comment)

Using that fixed this particular HUD alignment (both were clean installs).
The only mentionable difference between both case-lowering implementations is how they handle file renaming.