BizHawk/BizHawk.Client.Common/movie/MovieService.cs

42 lines
1.2 KiB
C#
Raw Normal View History

2014-06-29 03:03:27 +00:00
using System.Collections.Generic;
2014-06-11 02:33:57 +00:00
using System.IO;
using System.Linq;
namespace BizHawk.Client.Common
{
2014-06-11 21:14:13 +00:00
public static class MovieService
2014-06-11 02:33:57 +00:00
{
2014-06-12 11:53:25 +00:00
public static IMovie Get(string path)
2014-06-11 02:33:57 +00:00
{
2014-06-12 11:53:25 +00:00
// TODO: change IMovies to take HawkFiles only and not path
if (Path.GetExtension(path)?.EndsWith("tasproj") ?? false)
2014-06-14 20:17:07 +00:00
{
return new TasMovie(path);
}
return new Bk2Movie(path);
2014-06-11 02:33:57 +00:00
}
2014-06-12 11:53:25 +00:00
/// <summary>
/// Gets the file extension for the default movie implementation used in the client
/// </summary>
2020-02-20 18:50:50 +00:00
public const string DefaultExtension = "bk2";
2014-06-12 11:53:25 +00:00
/// <summary>
2017-05-09 18:19:55 +00:00
/// Gets a list of extensions for all <seealso cref="IMovie"/> implementations
2014-06-12 11:53:25 +00:00
/// </summary>
2020-02-20 18:50:50 +00:00
public static IEnumerable<string> MovieExtensions => new[] { DefaultExtension, TasMovie.Extension };
2014-06-12 21:45:47 +00:00
2014-06-14 14:09:55 +00:00
public static bool IsValidMovieExtension(string ext)
{
return MovieExtensions.Contains(ext.ToLower().Replace(".", ""));
2014-06-14 14:09:55 +00:00
}
2014-06-12 21:45:47 +00:00
/// <summary>
/// Creates a default instance of the default implementation,
/// no path is specified so this is in a minimal state that would not be able to be saved
/// </summary>
2017-05-09 18:19:55 +00:00
public static IMovie DefaultInstance => new Bk2Movie();
2014-06-11 02:33:57 +00:00
}
}