Ejemplo n.º 1
0
        public static NezPlugM3uEntry[] GetNezPlugM3uEntriesFromFile(string pPath)
        {
            NezPlugM3uEntry[] m3uEntries = null;
            ArrayList         m3uList    = new ArrayList();

            if (File.Exists(pPath))
            {
                using (StreamReader sr = new StreamReader(File.OpenRead(pPath)))
                {
                    string currentLine;

                    while ((currentLine = sr.ReadLine()) != null)
                    {
                        if (!currentLine.StartsWith(COMMENT_MARKER) &&
                            (!String.IsNullOrEmpty(currentLine)))
                        {
                            NezPlugM3uEntry m3uEntry = new NezPlugM3uEntry();
                            m3uEntry = GetNezPlugM3uEntryFromString(currentLine);

                            if (!String.IsNullOrEmpty(m3uEntry.filename))
                            {
                                m3uList.Add(m3uEntry);
                            }
                        }
                    }
                    m3uEntries = (NezPlugM3uEntry[])m3uList.ToArray(typeof(NezPlugM3uEntry));
                }
            }
            else
            {
                throw new IOException(String.Format("File not found: <{0}>{1}", pPath, Environment.NewLine));
            }

            return(m3uEntries);
        }
Ejemplo n.º 2
0
        public static NezPlugM3uEntry GetNezPlugM3uEntryFromString(string pString)
        {
            NezPlugM3uEntry m3uEntry = new NezPlugM3uEntry();

            string escapedCommaString = "\\,";
            string replaceCommaString = "|*|";
            string plainCommaString   = ",";

            string[] stringDelimtier = new string[] { "::" };
            string[] splitLine       = pString.Split(stringDelimtier, StringSplitOptions.None);

            if (splitLine.Length > 1)
            {
                char[] charDelimtier = new char[] { ',' };

                splitLine[1] = splitLine[1].Replace(escapedCommaString, replaceCommaString);
                string[] splitData = splitLine[1].Split(charDelimtier, StringSplitOptions.None);

                if (splitLine.Length > 0)
                {
                    m3uEntry.filename = splitLine[0].Replace(replaceCommaString, plainCommaString);
                }

                if (splitData.Length > 0)
                {
                    m3uEntry.format = splitData[0].Replace(replaceCommaString, plainCommaString);
                }

                if (splitData.Length > 1)
                {
                    m3uEntry.songNumber = (int)VGMToolbox.util.ByteConversion.GetLongValueFromString(splitData[1].Replace(replaceCommaString, plainCommaString).Replace("$", "0x"));
                }
                else
                {
                    m3uEntry.songNumber = EMPTY_COUNT;
                }

                if (splitData.Length > 2)
                {
                    m3uEntry.title = splitData[2].Replace(replaceCommaString, plainCommaString);
                }

                if (splitData.Length > 3)
                {
                    m3uEntry.time = splitData[3].Replace(replaceCommaString, plainCommaString);
                }

                if (splitData.Length > 4)
                {
                    m3uEntry.loop = splitData[4].Replace(replaceCommaString, plainCommaString);
                }

                if (splitData.Length > 5)
                {
                    m3uEntry.fade = splitData[5].Replace(replaceCommaString, plainCommaString);
                }

                if (splitData.Length > 6)
                {
                    m3uEntry.loopCount = splitData[6].Replace(replaceCommaString, plainCommaString);
                }
            }

            return(m3uEntry);
        }