-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix handling of paths modified by penumbra
- Loading branch information
1 parent
f189429
commit 50ef65f
Showing
2 changed files
with
34 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Meddle.Utils.Files.SqPack; | ||
|
||
namespace Meddle.Plugin.Utils; | ||
|
||
public static class PathUtil | ||
{ | ||
public static byte[]? GetFileOrReadFromDisk(this SqPack pack, string path) | ||
{ | ||
// if path is in format |...|path/to/file, trim the |...| part | ||
if (path[0] == '|') | ||
{ | ||
path = path.Substring(path.IndexOf('|', 1) + 1); | ||
} | ||
|
||
// if path is rooted, get from disk | ||
if (Path.IsPathRooted(path)) | ||
{ | ||
var data = File.ReadAllBytes(path); | ||
return data; | ||
} | ||
|
||
var file = pack.GetFile(path); | ||
return file?.file.RawData.ToArray(); | ||
} | ||
} |