Files
EHS/src/system/System_LNX.cpp

62 lines
999 B
C++

#include "ehs/system/System_LNX.h"
#include <cstdlib>
#include <cstdio>
#include "ehs/system/Thread.h"
namespace ehs
{
UInt_32 XDG_Thread(void* args)
{
Str_8* uri = (Str_8*)args;
system("xdg-open \"" + *uri + "\"");
return 0;
}
void System::OpenURI(const Str_8& uri)
{
Thread xdg;
xdg.Start(XDG_Thread, (void*)&uri);
xdg.Detach();
}
Str_8 System::OpenFileDialog(const Str_8 &dir, const Str_8 &filters)
{
FILE *file = popen("kdialog --getopenfilename " + dir + " \'" + filters + "\'", "r");
Str_8 result;
char array[128];
while(fgets(array, sizeof(array), file))
result.Push(array);
pclose(file);
if (result.Size())
result.Pop();
return result;
}
Str_8 System::GetDirDialog(const Str_8 &dir)
{
FILE *file = popen("kdialog --getexistingdirectory " + dir, "r");
Str_8 result;
char array[128];
while(fgets(array, sizeof(array), file))
result.Push(array);
pclose(file);
if (result.Size())
result.Pop();
return result;
}
}