/// <inheritdoc /> public override byte[] GetAsset(string enginePath) { // Convert to embedded path. bool found = InternalManifest.TryGetValue(enginePath, out string embeddedPath); // Check if found. if (!found) { return(new byte[0]); } byte[] data; // Read the asset from the embedded file. using (Stream stream = Assembly.GetManifestResourceStream(embeddedPath)) { // Not found. if (stream == null) { Engine.Log.Error($"Couldn't read asset [{enginePath}] with embedded path [{embeddedPath}].", MessageSource.AssetLoader); return(new byte[0]); } // Read from stream. data = new byte[stream.Length]; stream.Read(data, 0, (int)stream.Length); } return(data); }
/// <inheritdoc /> public override DateTime GetAssetModified(string enginePath) { // Convert to file path. bool found = InternalManifest.TryGetValue(enginePath, out string filePath); // Check if found. if (!found) { return(base.GetAssetModified(enginePath)); } // The API actually allows for a file to be modified before it was created. lol DateTime lastWrite = File.GetLastWriteTimeUtc(filePath); DateTime creationTime = File.GetCreationTimeUtc(filePath); int later = DateTime.Compare(lastWrite, creationTime); return(later > 0 ? lastWrite : creationTime); }
/// <inheritdoc /> public override byte[] GetAsset(string enginePath) { // Convert to file path. bool found = InternalManifest.TryGetValue(enginePath, out string filePath); // Check if found. if (!found) { return(new byte[0]); } // Check if exists. if (File.Exists(filePath)) { return(File.ReadAllBytes(filePath)); } Engine.Log.Error($"Couldn't read asset {enginePath} with file path {filePath}.", MessageSource.AssetLoader); return(new byte[0]); }