This repository has been archived on 2023-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
Blarg.GameFramework/Blarg.GameFramework.SDL2/IO/SDLFileSystem.cs

39 lines
746 B
C#
Raw Normal View History

2013-08-15 18:41:41 -04:00
using System;
using System.IO;
using System.Reflection;
using SDL2;
namespace Blarg.GameFramework.IO
{
public class SDLFileSystem : IFileSystem
{
string _assetsPath;
public SDLFileSystem()
{
string executablePath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
_assetsPath = Path.Combine(executablePath, "assets");
}
public Stream Open(string filename)
{
string realPath = TranslateFilePath(filename);
return new FileStream(realPath, FileMode.Open);
}
public string TranslateFilePath(string path)
{
if (path.StartsWith("assets://"))
return Path.Combine(_assetsPath, path.Substring(9));
else
return path;
}
public string AssetsPath
{
get { return _assetsPath; }
}
}
}