Example #1
0
        public IArchData ToArchData(byte[] wave, string waveExt, Dictionary <string, object> context = null)
        {
            if (!File.Exists(ToolPath))
            {
                return(null);
            }

            var tempFile = Path.GetTempFileName();

            File.WriteAllBytes(tempFile, wave);
            var          tempOutFile = Path.GetTempFileName();
            MemoryStream oms         = null;

            try
            {
                ProcessStartInfo info = new ProcessStartInfo(ToolPath, $"\"{tempFile}\" \"{tempOutFile}\"")
                {
                    WindowStyle    = ProcessWindowStyle.Hidden,
                    CreateNoWindow = true
                };
                Process process = Process.Start(info);
                process?.WaitForExit();

                var fs = File.OpenRead(tempOutFile);
                oms = new MemoryStream((int)fs.Length);
                fs.CopyTo(oms);
                oms.Position = 0;

                File.Delete(tempFile);
                File.Delete(tempOutFile);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            if (oms == null)
            {
                return(null);
            }

            XwmaArchData data = new XwmaArchData();

            data.ReadFromXwma(oms);
            oms.Dispose();

            return(data);
        }
Example #2
0
        public bool TryGetArchData(PSB psb, PsbDictionary dic, out IArchData data)
        {
            data = null;
            if (psb.Platform == PsbSpec.win)
            {
                if (dic.Count == 1 && dic["archData"] is PsbDictionary archDic && archDic["data"] is PsbResource aData && archDic["dpds"] is PsbResource aDpds && archDic["fmt"] is PsbResource aFmt && archDic["wav"] is PsbString aWav)
                {
                    data = new XwmaArchData()
                    {
                        Data = aData,
                        Fmt  = aFmt,
                        Dpds = aDpds,
                        Wav  = aWav.Value
                    };

                    return(true);
                }

                return(false);
            }

            return(false);
        }