Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*nix case patch: Remaining Uppercase directories #52

Open
Singustromo opened this issue Jul 24, 2023 · 13 comments
Open

*nix case patch: Remaining Uppercase directories #52

Singustromo opened this issue Jul 24, 2023 · 13 comments

Comments

@Singustromo
Copy link
Contributor

Singustromo commented Jul 24, 2023

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.

@Singustromo
Copy link
Contributor Author

Singustromo commented Jul 24, 2023

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.

@Mord3rca
Copy link
Owner

Mord3rca commented Jul 28, 2023

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

@Singustromo
Copy link
Contributor Author

Singustromo commented Jul 28, 2023

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.

@Singustromo Singustromo changed the title Windows case-insensitivity: Remaining Uppercase directories NTFS case-insensitivity: Remaining Uppercase directories Jul 28, 2023
@Mord3rca
Copy link
Owner

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 ?

@Mord3rca Mord3rca changed the title NTFS case-insensitivity: Remaining Uppercase directories *nix case patch: Remaining Uppercase directories Jul 29, 2023
@Singustromo
Copy link
Contributor Author

Singustromo commented Jul 29, 2023

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

@Mord3rca
Copy link
Owner

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

@Singustromo
Copy link
Contributor Author

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.

@Mord3rca
Copy link
Owner

Mord3rca commented Aug 6, 2023

New modification, it should be good now.

@sobkas
Copy link
Contributor

sobkas commented Aug 6, 2023

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

@Mord3rca
Copy link
Owner

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

@sobkas
Copy link
Contributor

sobkas commented Aug 10, 2023

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.

@Mord3rca
Copy link
Owner

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.

@Singustromo
Copy link
Contributor Author

Singustromo commented Oct 4, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants