X Tutup
Skip to content

Commit d4bba1c

Browse files
CYF 0.6.6 LTS 1
1 parent 587ef64 commit d4bba1c

File tree

17 files changed

+553
-741
lines changed

17 files changed

+553
-741
lines changed

Assets/Plugins/MoonSharp/Interpreter/CoreLib/LoadModule.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -286,19 +286,17 @@ public static bool RequireFile(ref string fileName, string pathSuffix, bool erro
286286
}
287287

288288
// Check if the resource exists using the mod path
289-
string modPath = pathSuffix;
290289
string error;
291290
try {
291+
string modPath = pathSuffix;
292292
ExplorePath(ref fileNameMod, ref modPath);
293-
// Keep the mod path even if the file needs to exist
293+
if (needsToExist && !new FileInfo(fileNameMod).Exists) throw new CYFException("The file " + fileNameMod + " doesn't exist.");
294294
fileName = fileNameMod;
295295

296-
if (!needsAbsolutePath) {
297-
Uri uriRel = new Uri(modPath).MakeRelativeUri(new Uri(fileName));
298-
fileName = Uri.UnescapeDataString(uriRel.OriginalString);
299-
}
296+
if (needsAbsolutePath) return true;
300297

301-
if (needsToExist && !new FileInfo(fileNameMod).Exists) throw new CYFException("The file " + fileNameMod + " doesn't exist.");
298+
Uri uriRel = new Uri(modPath + Path.DirectorySeparatorChar).MakeRelativeUri(new Uri(fileName));
299+
fileName = Uri.UnescapeDataString(uriRel.OriginalString);
302300
return true;
303301
} catch (Exception e) { error = e.Message; }
304302

@@ -342,9 +340,6 @@ public static void ExplorePath(ref string fullPath, ref string pathSuffix) {
342340

343341
fullPath = fullPath.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar);
344342

345-
if (!new DirectoryInfo(pathSuffix).Exists)
346-
throw new CYFException("The root folder \"" + pathSuffix + "\" doesn't exist.");
347-
348343
// Get the folder containing the resource to load
349344
string fileName = fullPath.Substring(fullPath.LastIndexOf(Path.DirectorySeparatorChar) + 1);
350345
DirectoryInfo endFolder = new DirectoryInfo(fullPath.Substring(0, fullPath.LastIndexOf(Path.DirectorySeparatorChar)));

0 commit comments

Comments
 (0)
X Tutup