fixed folder command

This commit is contained in:
BADIM-PC\Vadim 2018-02-13 19:39:26 +03:00
parent a3126275b4
commit 4b2db873a7
6 changed files with 51 additions and 39 deletions

View File

@ -143,7 +143,6 @@ int _wremove(const wchar_t *);
#define tic_remove _wremove #define tic_remove _wremove
#define tic_fopen _wfopen #define tic_fopen _wfopen
#define tic_mkdir(name) _wmkdir(name) #define tic_mkdir(name) _wmkdir(name)
#define tic_system _wsystem
#else #else
@ -162,7 +161,6 @@ int _wremove(const wchar_t *);
#define tic_remove remove #define tic_remove remove
#define tic_fopen fopen #define tic_fopen fopen
#define tic_mkdir(name) mkdir(name)//, 0700) #define tic_mkdir(name) mkdir(name)//, 0700)
#define tic_system system
#endif #endif
@ -771,38 +769,6 @@ void fsMakeDir(FileSystem* fs, const char* name)
makeDir(getFilePath(fs, name)); makeDir(getFilePath(fs, name));
} }
#if defined(__TIC_WINDOWS__) || defined(__LINUX__) || defined(__MACOSX__)
s32 fsOpenSystemPath(FileSystem* fs, const char* path)
{
char command[FILENAME_MAX];
#if defined(__TIC_WINDOWS__)
sprintf(command, "explorer \"%s\"", path);
#elif defined(__LINUX__)
sprintf(command, "xdg-open \"%s\"", path);
#elif defined(__MACOSX__)
sprintf(command, "open \"%s\"", path);
#endif
return tic_system(UTF8ToString(command));
}
#else
s32 fsOpenSystemPath(FileSystem* fs, const char* path)
{
return 0;
}
#endif
void fsOpenWorkingFolder(FileSystem* fs) void fsOpenWorkingFolder(FileSystem* fs)
{ {
const char* path = getFilePath(fs, ""); const char* path = getFilePath(fs, "");
@ -810,7 +776,7 @@ void fsOpenWorkingFolder(FileSystem* fs)
if(isPublic(fs)) if(isPublic(fs))
path = fs->dir; path = fs->dir;
fsOpenSystemPath(fs, path); openSystemPath(path);
} }
void createFileSystem(const char* path, void(*callback)(FileSystem*)) void createFileSystem(const char* path, void(*callback)(FileSystem*))

View File

@ -72,7 +72,6 @@ bool fsCopyFile(const char* src, const char* dst);
void fsGetFileData(GetCallback callback, const char* name, void* buffer, size_t size, u32 mode, void* data); void fsGetFileData(GetCallback callback, const char* name, void* buffer, size_t size, u32 mode, void* data);
void fsOpenFileData(OpenCallback callback, void* data); void fsOpenFileData(OpenCallback callback, void* data);
void fsOpenWorkingFolder(FileSystem* fs); void fsOpenWorkingFolder(FileSystem* fs);
s32 fsOpenSystemPath(FileSystem* fs, const char* path);
bool fsIsDir(FileSystem* fs, const char* dir); bool fsIsDir(FileSystem* fs, const char* dir);
bool fsIsInPublicDir(FileSystem* fs); bool fsIsInPublicDir(FileSystem* fs);
bool fsChangeDir(FileSystem* fs, const char* dir); bool fsChangeDir(FileSystem* fs, const char* dir);

View File

@ -950,6 +950,42 @@ static void _setWindowTitle(const char* title)
SDL_SetWindowTitle(platform.window, title); SDL_SetWindowTitle(platform.window, title);
} }
#if defined(__WINDOWS__) || defined(__LINUX__) || defined(__MACOSX__)
static void _openSystemPath(const char* path)
{
char command[FILENAME_MAX];
#if defined(__WINDOWS__)
sprintf(command, "explorer \"%s\"", path);
printf("%s\n", command);
wchar_t wcommand[FILENAME_MAX];
mbstowcs(wcommand, command, FILENAME_MAX);
_wsystem(wcommand);
#elif defined(__LINUX__)
sprintf(command, "xdg-open \"%s\"", path);
system(command);
#elif defined(__MACOSX__)
sprintf(command, "open \"%s\"", path);
system(command);
#endif
}
#else
void _openSystemPath(const char* path) {}
#endif
static System sysHandlers = static System sysHandlers =
{ {
.setClipboardText = _setClipboardText, .setClipboardText = _setClipboardText,
@ -968,6 +1004,8 @@ static System sysHandlers =
.goFullscreen = _goFullscreen, .goFullscreen = _goFullscreen,
.showMessageBox = _showMessageBox, .showMessageBox = _showMessageBox,
.setWindowTitle = _setWindowTitle, .setWindowTitle = _setWindowTitle,
.openSystemPath = _openSystemPath,
}; };
s32 main(s32 argc, char **argv) s32 main(s32 argc, char **argv)

View File

@ -2151,3 +2151,8 @@ void showMessageBox(const char* title, const char* message)
{ {
studioImpl.system->showMessageBox(title, message); studioImpl.system->showMessageBox(title, message);
} }
void openSystemPath(const char* path)
{
studioImpl.system->openSystemPath(path);
}

View File

@ -238,6 +238,8 @@ typedef struct
void (*showMessageBox)(const char* title, const char* message); void (*showMessageBox)(const char* title, const char* message);
void (*setWindowTitle)(const char* title); void (*setWindowTitle)(const char* title);
void (*openSystemPath)(const char* path);
} System; } System;
TIC80_API Studio* studioInit(s32 argc, char **argv, s32 samplerate, const char* appFolder, System* system); TIC80_API Studio* studioInit(s32 argc, char **argv, s32 samplerate, const char* appFolder, System* system);
@ -273,3 +275,5 @@ NetVersion netVersionRequest(Net* net);
void netDirRequest(Net* net, const char* path, ListCallback callback, void* data); void netDirRequest(Net* net, const char* path, ListCallback callback, void* data);
void showMessageBox(const char* title, const char* message); void showMessageBox(const char* title, const char* message);
TIC80_API void updateStudioProject(); TIC80_API void updateStudioProject();
void openSystemPath(const char* path);

View File

@ -781,7 +781,7 @@ static void processGamepad(Surf* surf)
{ {
char url[FILENAME_MAX]; char url[FILENAME_MAX];
sprintf(url, "https://" TIC_HOST "/play?cart=%i", item->id); sprintf(url, "https://" TIC_HOST "/play?cart=%i", item->id);
fsOpenSystemPath(surf->fs, url); openSystemPath(url);
} }
} }
#endif #endif