gmadsharp/src/addoncreator/AddonFileInfo.cs

22 lines
524 B
C#
Raw Normal View History

2014-10-22 13:47:38 +00:00
using CRC32;
namespace GarrysMod.AddonCreator
{
public abstract class AddonFileInfo
{
private int? _hash;
2014-10-22 17:48:30 +00:00
private long? _size;
2014-10-22 13:47:38 +00:00
2014-10-22 17:48:30 +00:00
public virtual long Size
{
get { return _size.HasValue ? _size.Value : (_size = GetContents().Length).Value; }
}
2014-10-22 13:47:38 +00:00
2014-10-22 17:48:30 +00:00
public virtual int Crc32Hash
{
get { return _hash.HasValue ? _hash.Value : (_hash = ParallelCRC.Compute(GetContents())).Value; }
}
2014-10-22 13:47:38 +00:00
public abstract byte[] GetContents();
}
}