Browse Source

Fixed bug when trying to load a file from the current path.

Vicente Penades 5 years ago
parent
commit
c2e33360e5
1 changed files with 6 additions and 1 deletions
  1. 6 1
      src/SharpGLTF.Core/IO/ReadContext.cs

+ 6 - 1
src/SharpGLTF.Core/IO/ReadContext.cs

@@ -39,14 +39,19 @@ namespace SharpGLTF.IO
 
 
         public static ReadContext CreateFromFile(string filePath)
         public static ReadContext CreateFromFile(string filePath)
         {
         {
+            Guard.NotNull(filePath, nameof(filePath));
             Guard.FilePathMustExist(filePath, nameof(filePath));
             Guard.FilePathMustExist(filePath, nameof(filePath));
+
             var dir = Path.GetDirectoryName(filePath);
             var dir = Path.GetDirectoryName(filePath);
             return CreateFromDirectory(dir);
             return CreateFromDirectory(dir);
         }
         }
 
 
         public static ReadContext CreateFromDirectory(string directoryPath)
         public static ReadContext CreateFromDirectory(string directoryPath)
         {
         {
-            directoryPath = System.IO.Path.GetFullPath(directoryPath);
+            Guard.NotNull(directoryPath, nameof(directoryPath));
+
+            if (string.IsNullOrEmpty(directoryPath)) directoryPath = Environment.CurrentDirectory;
+            else directoryPath = System.IO.Path.GetFullPath(directoryPath);
 
 
             string _uriSolver(string rawUri)
             string _uriSolver(string rawUri)
             {
             {