mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-03-03 20:46:37 +00:00
fixing file access
This commit is contained in:
@@ -238,6 +238,15 @@ extern "C"
|
|||||||
mlx::Error("Image loader: not a valid file format '%'", filename);
|
mlx::Error("Image loader: not a valid file format '%'", filename);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::ifstream stream(file, std::ios::binary);
|
||||||
|
if(!stream.is_open())
|
||||||
|
{
|
||||||
|
mlx::Error("Image loader: failed to open file '%'", filename);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
return mlx->app->NewStbTexture(filename, width, height);
|
return mlx->app->NewStbTexture(filename, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,11 +321,21 @@ extern "C"
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(std::strcmp(filepath, "default") != 0 && file.extension() != ".ttf" && file.extension() != ".tte")
|
if(std::strcmp(filepath, "default") != 0)
|
||||||
{
|
{
|
||||||
mlx::Error("TTF loader: not a truetype font file '%'", filepath);
|
if(file.extension() != ".ttf" && file.extension() != ".tte")
|
||||||
return;
|
{
|
||||||
|
mlx::Error("TTF loader: not a truetype font file '%'", filepath);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::ifstream stream(file, std::ios::binary);
|
||||||
|
if(!stream.is_open())
|
||||||
|
{
|
||||||
|
mlx::Error("TTF loader: failed to open font file '%'", filepath);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(std::strcmp(filepath, "default") == 0)
|
if(std::strcmp(filepath, "default") == 0)
|
||||||
mlx->app->LoadFont(file, 6.f);
|
mlx->app->LoadFont(file, 6.f);
|
||||||
else
|
else
|
||||||
@@ -339,11 +358,21 @@ extern "C"
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(std::strcmp(filepath, "default") != 0 && file.extension() != ".ttf" && file.extension() != ".tte")
|
if(std::strcmp(filepath, "default") != 0)
|
||||||
{
|
{
|
||||||
mlx::Error("TTF loader: not a truetype font file '%'", filepath);
|
if(file.extension() != ".ttf" && file.extension() != ".tte")
|
||||||
return;
|
{
|
||||||
|
mlx::Error("TTF loader: not a truetype font file '%'", filepath);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::ifstream stream(file, std::ios::binary);
|
||||||
|
if(!stream.is_open())
|
||||||
|
{
|
||||||
|
mlx::Error("TTF loader: failed to open font file '%'", filepath);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mlx->app->LoadFont(file, scale);
|
mlx->app->LoadFont(file, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user