wabbajack/Wabbajack.Compiler/RawSourceFile.cs

41 lines
925 B
C#
Raw Normal View History

2021-09-27 12:42:46 +00:00
using System.IO;
using Wabbajack.DTOs;
using Wabbajack.Hashing.xxHash64;
using Wabbajack.Paths;
using Wabbajack.VFS;
2021-10-23 16:51:17 +00:00
namespace Wabbajack.Compiler;
/// <summary>
/// Contains everything we know about a given file from the source folder
/// </summary>
public class RawSourceFile
2021-09-27 12:42:46 +00:00
{
2021-10-23 16:51:17 +00:00
public readonly RelativePath Path;
2021-09-27 12:42:46 +00:00
2021-10-23 16:51:17 +00:00
public RawSourceFile(VirtualFile file, RelativePath path)
{
File = file;
Path = path;
}
2021-09-27 12:42:46 +00:00
2021-10-23 16:51:17 +00:00
public AbsolutePath AbsolutePath
{
get
2021-09-27 12:42:46 +00:00
{
2021-10-23 16:51:17 +00:00
if (!File.IsNative)
throw new InvalidDataException("Can't get the absolute path of a non-native file");
return File.FullPath.Base;
2021-09-27 12:42:46 +00:00
}
2021-10-23 16:51:17 +00:00
}
2021-09-27 12:42:46 +00:00
2021-10-23 16:51:17 +00:00
public VirtualFile File { get; }
2021-09-27 12:42:46 +00:00
2021-10-23 16:51:17 +00:00
public Hash Hash => File.Hash;
2021-09-27 12:42:46 +00:00
2021-10-23 16:51:17 +00:00
public T EvolveTo<T>() where T : Directive, new()
{
var v = new T {To = Path, Hash = File.Hash, Size = File.Size};
return v;
2021-09-27 12:42:46 +00:00
}
}