//converts one file, returns true if conversion successfull
        public static bool ConvertOne(string input, ConversionProperties props)
        {
            if (props == null)
            {
                props = AssessProperties(input);
                if (props == null) return false;
            }

            ProcessStartInfo info = new ProcessStartInfo(props.ww2ogg_Location, props.ww2ogg_Parameters + " " + "\"" + input + "\"");
            info.CreateNoWindow = true;
            info.WindowStyle = ProcessWindowStyle.Hidden;

            Process ww2ogg = Process.Start(info);
            ww2ogg.WaitForExit();
            if (ww2ogg.ExitCode != 0) return false;

            if (props.revorb_Use)
            {
                info = new ProcessStartInfo(props.revorb_Location, "\"" + input.Substring(0, input.LastIndexOf('.')) + ".ogg" + "\"");
                info.CreateNoWindow = true;
                info.WindowStyle = ProcessWindowStyle.Hidden;

                Process revorb = Process.Start(info);
                revorb.WaitForExit();
            }

            return true;
        }
        //converts many files, returns number of successfully converted files
        public static int ConvertRange(List<string> files, ConversionProperties props)
        {
            int converted = 0;
            Progress.Start_Converting(files.Count);

            foreach (string file in files)
            {
                if (ConvertOne(file, props))
                {
                    converted++;
                    Progress.Conversion_Update();
                }
            }

            return converted;
        }
        public static int ProcessOne(string filename, string destination, ConversionProperties props)
        {
            int n = 0;

            string safename = filename.Substring(filename.LastIndexOf('\\') + 1);

            if (filename.EndsWith(".pcc"))
            {
                ProcessStartInfo info = new ProcessStartInfo("data\\decompress.exe", "-out=\"" + destination + "\\temp\" \"" + filename + "\"");
                info.CreateNoWindow = true;
                info.WindowStyle = ProcessWindowStyle.Hidden;

                Process unpack = Process.Start(info);
                unpack.WaitForExit();
                filename = destination + "\\temp\\" + safename;
            }

            List<long[]> positions = Scanner.Scan(filename);

            List<string> filenames = Extractor.Extract(filename, destination, positions);

            if (Directory.Exists(destination + "\\temp"))
                Directory.Delete(destination + "\\temp", true);

            if (props==null && filenames.Count>0)
                props = Converter.AssessProperties(filenames[0]);

            n = Converter.ConvertRange(filenames, props);

            foreach (string fn in filenames)
            {
                string s = fn.Substring(0, fn.LastIndexOf('.')) + ".wav";
                if (File.Exists(s))
                    File.Delete(s);
            }
            Progress.File_Complete();

            return n;
        }