bool LoadAsset (string assetPath, byte [] data, out AssetBase asset)
{
string filename = assetPath.Remove (0, ArchiveConstants.ASSETS_PATH.Length);
int i = filename.LastIndexOf (ArchiveConstants.ASSET_EXTENSION_SEPARATOR, StringComparison.Ordinal);
if (i == -1) {
MainConsole.Instance.ErrorFormat (
"[Archiver]: Could not find extension information in asset path {0} since it's missing the separator {1}. Skipping",
assetPath, ArchiveConstants.ASSET_EXTENSION_SEPARATOR);
asset = null;
return false;
}
string extension = filename.Substring (i);
string uuid = filename.Remove (filename.Length - extension.Length);
if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey (extension)) {
AssetType assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE [extension];
if (assetType == AssetType.Unknown)
MainConsole.Instance.WarnFormat ("[Archiver]: Importing {0} byte asset {1} with unknown type",
data.Length, uuid);
asset = new AssetBase (UUID.Parse (uuid), string.Empty, assetType, UUID.Zero) { Data = data };
return true;
}
MainConsole.Instance.ErrorFormat (
"[Archiver]: Tried to de-archive data with path {0} with an unknown type extension {1}",
assetPath, extension);
asset = null;
return false;
}