public static void BuildM3uForFile(NsfM3uBuilderStruct pNsfM3uBuilderStruct) { using (FileStream fs = File.OpenRead(pNsfM3uBuilderStruct.Path)) { Type dataType = FormatUtil.getObjectType(fs); System.Text.Encoding enc = System.Text.Encoding.ASCII; if (dataType != null && dataType.Name.Equals("Nsfe")) { string filename = Path.GetFileName(pNsfM3uBuilderStruct.Path); string trackItem = String.Empty; Nsfe nsfeData = new Nsfe(); fs.Seek(0, SeekOrigin.Begin); nsfeData.Initialize(fs, pNsfM3uBuilderStruct.Path); string outputFile = Path.GetDirectoryName(pNsfM3uBuilderStruct.Path) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(pNsfM3uBuilderStruct.Path) + ".m3u"; using (StreamWriter sw = File.CreateText(outputFile)) { string[] playlist = nsfeData.Playlist.Split(','); sw.WriteLine("#######################################################"); sw.WriteLine("#"); sw.WriteLine("# Game: " + nsfeData.SongName); sw.WriteLine("# Artist: " + nsfeData.SongArtist); sw.WriteLine("# Copyright: " + nsfeData.SongCopyright); sw.WriteLine("# Ripper: " + nsfeData.NsfRipper); sw.WriteLine("#"); sw.WriteLine("#######################################################"); sw.WriteLine(); // Build by playlist if it exists if (!String.IsNullOrEmpty(nsfeData.Playlist)) { int fileIndex = 1; int index; foreach (string s in nsfeData.Playlist.Split(',')) { index = int.Parse(s.Trim()); trackItem = NsfUtil.BuildTrackItem(index, nsfeData, pNsfM3uBuilderStruct.Path); sw.WriteLine(trackItem); if (pNsfM3uBuilderStruct.OnePlaylistPerFile) { NsfUtil.BuildSingleFileM3u(pNsfM3uBuilderStruct.Path, nsfeData, trackItem, fileIndex, index); } fileIndex++; } } // Use default order if playlist does not exist else { // !!! CHANGE TO START FROM nsfeData.StartingSong??????? for (int i = 0; i < nsfeData.TotalSongs[0]; i++) { trackItem = NsfUtil.BuildTrackItem(i, nsfeData, pNsfM3uBuilderStruct.Path); sw.WriteLine(trackItem); if (pNsfM3uBuilderStruct.OnePlaylistPerFile) { NsfUtil.BuildSingleFileM3u(pNsfM3uBuilderStruct.Path, nsfeData, trackItem, i, i); } } } } NsfUtil.NsfeToNsf(nsfeData, pNsfM3uBuilderStruct.Path); } } }