private byte[] GetRawData(AudioClip clip) { if (AudioClip.IsReadLoadType(clip.File.Version)) { ResourcesFile res = clip.File.Collection.FindResourcesFile(clip.File, clip.FSBResource.Source); if (res == null) { Logger.Instance.Log(LogType.Warning, LogCategory.Export, $"Can't export '{clip.Name}' because resources file '{clip.FSBResource.Source}' wasn't found"); return(null); } res.Stream.Position = clip.FSBResource.Offset; if (StreamedResource.IsReadSize(clip.File.Version)) { byte[] buffer = new byte[clip.FSBResource.Size]; res.Stream.Read(buffer, 0, buffer.Length); return(buffer); } else { Logger.Instance.Log(LogType.Warning, LogCategory.Export, $"Can't export '{clip.Name}' because unknown raw data size"); return(null); } } else { return((byte[])clip.AudioData); } }
public override void ExportBinary(IExportContainer container, Stream stream) { if (IsReadLoadType(container.Version)) { using (ResourcesFile res = File.Collection.FindResourcesFile(File, FSBResource.Source)) { if (res == null) { Logger.Log(LogType.Warning, LogCategory.Export, $"Can't export '{Name}' because resources file '{FSBResource.Source}' hasn't been found"); return; } if (StreamedResource.IsReadSize(container.Version)) { using (PartialStream resStream = new PartialStream(res.Stream, res.Offset, res.Size)) { resStream.Position = FSBResource.Offset; resStream.CopyStream(stream, FSBResource.Size); } } else { // I think they read data by its type for this verison, so I can't even export raw data :/ Logger.Log(LogType.Warning, LogCategory.Export, $"Can't export '{Name}' because of unknown size"); } } } else { if (IsReadStreamingInfo(container.Version)) { if (Stream == 2) { using (ResourcesFile res = File.Collection.FindResourcesFile(File, StreamingInfo.Path)) { if (res == null) { Logger.Log(LogType.Warning, LogCategory.Export, $"Can't export '{Name}' because resources file '{StreamingInfo.Path}' hasn't been found"); return; } using (PartialStream resStream = new PartialStream(res.Stream, res.Offset, res.Size)) { resStream.Position = StreamingInfo.Offset; resStream.CopyStream(stream, StreamingInfo.Size); } } } else { stream.Write(m_audioData, 0, m_audioData.Length); } } else { stream.Write(m_audioData, 0, m_audioData.Length); } } }
public IReadOnlyList <byte> GetAudioData() { if (IsReadLoadType(File.Version)) { using (ResourcesFile res = File.Collection.FindResourcesFile(File, FSBResource.Source)) { if (res == null) { return(new byte[0]); } if (StreamedResource.IsReadSize(File.Version)) { byte[] data = new byte[FSBResource.Size]; using (PartialStream resStream = new PartialStream(res.Stream, res.Offset, res.Size)) { resStream.Position = FSBResource.Offset; resStream.ReadBuffer(data, 0, data.Length); } return(data); } else { return(new byte[0]); } } } else { if (IsReadStreamingInfo(File.Version)) { if (LoadType == AudioClipLoadType.Streaming) { if (m_audioData == null) { using (ResourcesFile res = File.Collection.FindResourcesFile(File, StreamingInfo.Path)) { if (res == null) { return(new byte[0]); } byte[] data = new byte[FSBResource.Size]; using (PartialStream resStream = new PartialStream(res.Stream, res.Offset, res.Size)) { resStream.Position = StreamingInfo.Offset; resStream.ReadBuffer(data, 0, data.Length); } return(data); } } } } return(m_audioData); } }
public override void ExportBinary(IAssetsExporter exporter, Stream stream) { if (IsReadLoadType(exporter.Version)) { ResourcesFile res = File.Collection.FindResourcesFile(File, FSBResource.Source); if (res == null) { Logger.Log(LogType.Warning, LogCategory.Export, $"Can't export '{Name}' because resources file '{FSBResource.Source}' wasn't found"); return; } res.Stream.Position = FSBResource.Offset; if (StreamedResource.IsReadSize(exporter.Version)) { res.Stream.CopyStream(stream, FSBResource.Size); } else { // I think they read data by it's type for this verison, so I can't even export raw data :/ } } else { if (IsReadStreamingInfo(exporter.Version)) { if (Stream == 2) { ResourcesFile res = File.Collection.FindResourcesFile(File, StreamingInfo.Path); if (res == null) { Logger.Log(LogType.Warning, LogCategory.Export, $"Can't export '{Name}' because resources file '{StreamingInfo.Path}' wasn't found"); return; } res.Stream.Position = FSBResource.Offset; res.Stream.CopyStream(stream, StreamingInfo.Size); } else { stream.Write(m_audioData, 0, m_audioData.Length); } } else { stream.Write(m_audioData, 0, m_audioData.Length); } } }