Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Bug AssetDatabase.CreateFolder creates folders with different case

Discussion in 'Asset Database' started by Darkgaze, Nov 4, 2022.

  1. Darkgaze

    Darkgaze

    Joined:
    Apr 3, 2017
    Posts:
    361
    So I run this code

    Code (CSharp):
    1.         string guid = AssetDatabase.CreateFolder("Assets/Ignore", "SteamedRice");
    2.         Debug.Log(AssetDatabase.GUIDToAssetPath(guid));
    3.  
    4.         guid = AssetDatabase.CreateFolder("Assets/Ignore", "Test");
    5.         Debug.Log(AssetDatabase.GUIDToAssetPath(guid));
    And it creates folder "SteamedRice" and "test". Note the lower-case of the second one.

    Is "test" for some reason a reserved name or a reserved type of folder?
    This is insane.
     
  2. Darkgaze

    Darkgaze

    Joined:
    Apr 3, 2017
    Posts:
    361
    Yeah, reporting bug. This is a very ugly one. Happening on 2022.2 and 2021.3 too.
    But NOT happening on Mac.


    Create file with name in lowercase.
    Create folder with same name in uppercase in the same place.
    The folder gets changed to lowercase too.

    Not happening if the file doesn't exist prior to creating the folder. That's it.


    Ugly, because in my project I have to create a folder called the same way as the scene there is in that same folder. That's not possible if you had another file already with the same name in another format.

    - sceneName <-- You can't create SceneName in upper case because of the Jpg.
    - SceneName.scene
    - sceneName.jpg
     
  3. Darkgaze

    Darkgaze

    Joined:
    Apr 3, 2017
    Posts:
    361
    Bug report sent.

    Create file ThisFILE
    Create folder thisfile
    Folder gets called ThisFILE

    Create file called HelloHi
    create folder called HELLOhi
    Folder gets called HelloHi
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    1,845
    Could you make a C# console app real quick that does the same?
    I believe this is generally an issue having both a file and a folder of the same name at the same location. I know I‘ve had weird issues (not unity related) because of that over the years but cannot recall a specific instance. Most likely associated with build pipelines, make, batch or bash scripts or tools like doc generators, code analyzers that tripped over such instances.
    I believe that wasn‘t even allowed until some version of Windows.
     
  5. Darkgaze

    Darkgaze

    Joined:
    Apr 3, 2017
    Posts:
    361
    So that's Windows related? Mmm... Ok. I have no idea how to make a c# console app, I have no time for that right now but I'll try asap (I basically learned c# via Unity, but I'm used to others like c++ and such). Apologies for not testing that!
     
  6. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    1,845
    I did a quick check with explorer (actually: Directory Opus) ...

    upload_2022-11-10_13-56-25.png

    I created a test.txt and then i tried to create a folder named test.txt and this is the error I got. I also tried creating the test.txt folder somewhere else and then moving it to the same folder as test.txt and I got a conflict resolution window where I was asked if I wanted to overwrite the existing test.txt file.

    It seems generally disallowed on Windows, though I know it can be done some way or another because I've had that happen to me one way or another and it was creating issues.
     
  7. Darkgaze

    Darkgaze

    Joined:
    Apr 3, 2017
    Posts:
    361
    I see. Thanks! My reported bug was accepted and seems to be under development. .... Who knows. If it's a typical windows problem, maybe they can sort it out somehow doing it differently?...