22 lines
629 B
C#
22 lines
629 B
C#
using Harmonia.Core.Data;
|
|
|
|
namespace Harmonia.Core.Playlists;
|
|
|
|
public class PlaylistRepository : JsonFileRepository<Playlist>
|
|
{
|
|
protected override string DirectoryName => string.Empty;
|
|
|
|
protected override string GetNewFileName()
|
|
{
|
|
for (int i = 0; i < 1000; i++)
|
|
{
|
|
string shortFileName = $"Playlist{i.ToString().PadLeft(3, '0')}.{Extension}";
|
|
string filePath = Path.Combine(DirectoryName, shortFileName);
|
|
|
|
if (File.Exists(filePath) == false)
|
|
return shortFileName;
|
|
}
|
|
|
|
throw new Exception("Unable to determine new fileName");
|
|
}
|
|
} |