Skip to content
This repository has been archived by the owner on Aug 31, 2020. It is now read-only.

Commit

Permalink
Fixed an issue in which full paths wouldn't work properly
Browse files Browse the repository at this point in the history
On Content.cs (I'm guessing by mistake) there was an addition of 2 strings that form a path. However, when the path provided is a full path then it doesn't make sens cause you end up with a full path followed by another full path. Using Path.Combine the standard library this case is taken care of.
```c#
rootPath + item.Path -> Path.Combine(rootPath, item.Path)
```
As for the other change in NPLConfigReader.cs, if the path provided is a full path instead of a relative path, then we don't really want to remove anything as it is already a correct path. So If the path is rooted just use the path as is:
```c#
string name = file;
if (!Path.IsPathRooted(file))
     name = file.Remove(0, rootDir.Length).Replace('\\', '/');
var newItem = new Item(name);
```
  • Loading branch information
OAguinagalde committed Jun 17, 2020
1 parent 28e070e commit b9aac72
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions NoPipeline/NoPipeline/Content.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ public void CheckIntegrity(string rootPath)
// Don't include if the file doesn't exist.
if (File.Exists(Path.Combine(rootPath, item.Path)))
{

DateTime itemLastModified = File.GetLastWriteTime(rootPath + item.Path);
// Using Path.Combine to prevent issues when one of the paths is a full path already
DateTime itemLastModified = File.GetLastWriteTime(Path.Combine(rootPath, item.Path));

var relativeItemPath = Path.Combine(rootPath, Path.GetDirectoryName(item.Path));

Expand Down
5 changes: 4 additions & 1 deletion NoPipeline/NoPipeline/NPLConfigReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ public void Read(Content content, string configPath)

foreach (var file in files)
{
var name = file.Remove(0, rootDir.Length).Replace('\\', '/');
// If the fail is already a valid and full path, we don't want to modify it.
string name = file;
if (!Path.IsPathRooted(file))
name = file.Remove(0, rootDir.Length).Replace('\\', '/');
var newItem = new Item(name);

Console.WriteLine(" Reading " + name);
Expand Down

0 comments on commit b9aac72

Please sign in to comment.