| 46 | TArray<FScriptPosition> IncludeLocs; |
| 47 | |
| 48 | static FString ResolveIncludePath(const FString &path,const FString &lumpname){ |
| 49 | if (path.IndexOf("./") == 0 || path.IndexOf("../") == 0) // relative path resolving |
| 50 | { |
| 51 | auto start = lumpname.LastIndexOf(":"); // find find separator between wad and path |
| 52 | |
| 53 | auto end = lumpname.LastIndexOf("/"); // find last '/' |
| 54 | |
| 55 | // it's a top-level file, if it's a folder being loaded ( /xxx/yyy/:whatever.zs ) end is before than start, or if it's a zip ( xxx.zip:whatever.zs ) end would be -1 |
| 56 | bool topLevelFile = start > end ; |
| 57 | |
| 58 | FString fullPath = topLevelFile ? FString {} : lumpname.Mid(start + 1, end - start - 1); // get path from lumpname (format 'wad:filepath/filename') |
| 59 | |
| 60 | if (start != -1) |
| 61 | { |
| 62 | FString relativePath = path; |
| 63 | if (relativePath.IndexOf("./") == 0) // strip initial marker |
| 64 | { |
| 65 | relativePath = relativePath.Mid(2); |
| 66 | } |
| 67 | |
| 68 | bool pathOk = true; |
| 69 | |
| 70 | while (relativePath.IndexOf("../") == 0) // go back one folder for each '..' |
| 71 | { |
| 72 | relativePath = relativePath.Mid(3); |
| 73 | auto slash_index = fullPath.LastIndexOf("/"); |
| 74 | if (slash_index != -1) |
| 75 | { |
| 76 | fullPath = fullPath.Mid(0, slash_index); |
| 77 | } |
| 78 | else if (fullPath.IsNotEmpty()) |
| 79 | { |
| 80 | fullPath = ""; |
| 81 | } |
| 82 | else |
| 83 | { |
| 84 | pathOk = false; |
| 85 | break; |
| 86 | } |
| 87 | } |
| 88 | if (pathOk) // if '..' parsing was successful |
| 89 | { |
| 90 | return topLevelFile ? relativePath : fullPath + "/" + relativePath; |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | return path; |
| 95 | } |
| 96 | |
| 97 | static FString ZCCTokenName(int terminal); |
| 98 | void AddInclude(ZCC_ExprConstant *node) |
no test coverage detected