//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 loyalsoft. All rights reserved.
// Homepage: http://www.game7000.com/
// Feedback: http://www.game7000.com/
//------------------------------------------------------------
using System.Runtime.InteropServices;
namespace GameFramework.FileSystem
{
///
/// 文件信息。
///
[StructLayout(LayoutKind.Auto)]
public struct FileInfo
{
private readonly string m_Name;
private readonly long m_Offset;
private readonly int m_Length;
///
/// 初始化文件信息的新实例。
///
/// 文件名称。
/// 文件偏移。
/// 文件长度。
public FileInfo(string name, long offset, int length)
{
if (string.IsNullOrEmpty(name))
{
throw new GameFrameworkException("Name is invalid.");
}
if (offset < 0L)
{
throw new GameFrameworkException("Offset is invalid.");
}
if (length < 0)
{
throw new GameFrameworkException("Length is invalid.");
}
m_Name = name;
m_Offset = offset;
m_Length = length;
}
///
/// 获取文件信息是否有效。
///
public bool IsValid
{
get
{
return !string.IsNullOrEmpty(m_Name) && m_Offset >= 0L && m_Length >= 0;
}
}
///
/// 获取文件名称。
///
public string Name
{
get
{
return m_Name;
}
}
///
/// 获取文件偏移。
///
public long Offset
{
get
{
return m_Offset;
}
}
///
/// 获取文件长度。
///
public int Length
{
get
{
return m_Length;
}
}
}
}