예제 #1
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                ExitMessage("Please drag a .bplist file onto this .exe", 1);
            }

            string path       = args[0];
            bool   fileExists = File.Exists(path);

            if (!fileExists)
            {
                ExitMessage("The specified file does not exist!", 1);
            }

            string text     = File.ReadAllText(path);
            var    legacy   = PlaylistConverter.DeserializeLegacyPlaylist(text);
            var    playlist = PlaylistConverter.ConvertLegacyPlaylist(legacy);

            string newPath = path.Replace(".bplist", ".blist");

            using (FileStream fs = File.Open(newPath, FileMode.OpenOrCreate))
            {
                using (MemoryStream ms = PlaylistLib.SerializeStream(playlist))
                {
                    ms.CopyTo(fs);
                    fs.Flush();
                }
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: lolPants/Blister
        static bool ConvertFile(string path)
        {
            bool fileExists = File.Exists(path);

            if (fileExists == false)
            {
                Console.WriteLine($"File \"{path}\" does not exist");
                return(false);
            }

            using (StreamReader file = File.OpenText(path))
            {
                try
                {
                    var legacy   = PlaylistConverter.DeserializeLegacyPlaylist(file);
                    var playlist = PlaylistConverter.ConvertLegacyPlaylist(legacy);

                    string newPath = path.Replace(".bplist", ".blist").Replace(".json", ".blist");
                    using (FileStream fs = File.Open(newPath, FileMode.OpenOrCreate))
                    {
                        PlaylistLib.SerializeStream(playlist, fs);
                        return(true);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Exception in {path}");
                    Console.WriteLine(ex.ToString());
                    return(false);
                }
            }
        }
예제 #3
0
 /* Overwrites a legacy playlist with Blister playlist. Does not change file name. */
 public static void OverwritePlaylist(string path, Playlist playlist)
 {
     using (FileStream fs = File.Open(path, FileMode.OpenOrCreate))
     {
         PlaylistLib.SerializeStream(playlist, fs);
     }
 }