Search Unity

[bug] cannot use case-sensitive file-system (f.e. default Linux)

Discussion in 'Addressables' started by nik_d, Jun 12, 2019.

  1. nik_d

    nik_d

    Joined:
    Apr 27, 2018
    Posts:
    66
    workaround: in HashingMethods.cs:

    Code (CSharp):
    1.         public static RawHash CalculateFile(string filePath)
    2.         {
    3.             RawHash rawHash;
    4.             using (var stream = new FileStream(FilePathCaseFixup(filePath), FileMode.Open, FileAccess.Read))
    5.                 rawHash = CalculateStream<MD5>(stream);
    6.             return rawHash;
    7.         }
    8.  
    9.         public static RawHash CalculateFile<T>(string filePath) where T : HashAlgorithm
    10.         {
    11.             RawHash rawHash;
    12.             using (var stream = new FileStream(FilePathCaseFixup(filePath), FileMode.Open, FileAccess.Read))
    13.                 rawHash = CalculateStream<T>(stream);
    14.             return rawHash;
    15.         }
    16.        
    17.         //**addressables - fix: atlas building for the case-sensitive file system
    18.         private const string FixPathPrefix = "Library/AtlasCache";
    19.         private static readonly string _fixPathPrefixLow = FixPathPrefix.ToLower();
    20.         private static string FilePathCaseFixup(string filePath)
    21.         {
    22.             if (filePath.StartsWith(_fixPathPrefixLow)) {
    23.                 return FixPathPrefix + filePath.Substring(_fixPathPrefixLow.Length);
    24.             }
    25.             return filePath;
    26.         }