diff --git a/src/fs.c b/src/fs.c index 5271571..a7ae6b7 100644 --- a/src/fs.c +++ b/src/fs.c @@ -143,7 +143,6 @@ int _wremove(const wchar_t *); #define tic_remove _wremove #define tic_fopen _wfopen #define tic_mkdir(name) _wmkdir(name) -#define tic_system _wsystem #else @@ -162,7 +161,6 @@ int _wremove(const wchar_t *); #define tic_remove remove #define tic_fopen fopen #define tic_mkdir(name) mkdir(name)//, 0700) -#define tic_system system #endif @@ -771,38 +769,6 @@ void fsMakeDir(FileSystem* fs, const char* 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) { const char* path = getFilePath(fs, ""); @@ -810,7 +776,7 @@ void fsOpenWorkingFolder(FileSystem* fs) if(isPublic(fs)) path = fs->dir; - fsOpenSystemPath(fs, path); + openSystemPath(path); } void createFileSystem(const char* path, void(*callback)(FileSystem*)) diff --git a/src/fs.h b/src/fs.h index b93fd43..e1af243 100644 --- a/src/fs.h +++ b/src/fs.h @@ -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 fsOpenFileData(OpenCallback callback, void* data); void fsOpenWorkingFolder(FileSystem* fs); -s32 fsOpenSystemPath(FileSystem* fs, const char* path); bool fsIsDir(FileSystem* fs, const char* dir); bool fsIsInPublicDir(FileSystem* fs); bool fsChangeDir(FileSystem* fs, const char* dir); diff --git a/src/main.c b/src/main.c index 8a21f14..b6a2406 100644 --- a/src/main.c +++ b/src/main.c @@ -950,6 +950,42 @@ static void _setWindowTitle(const char* 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 = { .setClipboardText = _setClipboardText, @@ -968,6 +1004,8 @@ static System sysHandlers = .goFullscreen = _goFullscreen, .showMessageBox = _showMessageBox, .setWindowTitle = _setWindowTitle, + + .openSystemPath = _openSystemPath, }; s32 main(s32 argc, char **argv) diff --git a/src/studio.c b/src/studio.c index ac01858..1010a71 100644 --- a/src/studio.c +++ b/src/studio.c @@ -2150,4 +2150,9 @@ void netDirRequest(Net* net, const char* path, ListCallback callback, void* data void showMessageBox(const char* title, const char* message) { studioImpl.system->showMessageBox(title, message); +} + +void openSystemPath(const char* path) +{ + studioImpl.system->openSystemPath(path); } \ No newline at end of file diff --git a/src/studio.h b/src/studio.h index a898d45..5554547 100644 --- a/src/studio.h +++ b/src/studio.h @@ -77,7 +77,7 @@ typedef struct s32 arrow; s32 hand; s32 ibeam; - + bool pixelPerfect; } cursor; @@ -238,6 +238,8 @@ typedef struct void (*showMessageBox)(const char* title, const char* message); void (*setWindowTitle)(const char* title); + void (*openSystemPath)(const char* path); + } System; TIC80_API Studio* studioInit(s32 argc, char **argv, s32 samplerate, const char* appFolder, System* system); @@ -272,4 +274,6 @@ typedef struct NetVersion netVersionRequest(Net* net); void netDirRequest(Net* net, const char* path, ListCallback callback, void* data); void showMessageBox(const char* title, const char* message); -TIC80_API void updateStudioProject(); \ No newline at end of file +TIC80_API void updateStudioProject(); + +void openSystemPath(const char* path); \ No newline at end of file diff --git a/src/surf.c b/src/surf.c index 1c6712a..4f41d06 100644 --- a/src/surf.c +++ b/src/surf.c @@ -781,7 +781,7 @@ static void processGamepad(Surf* surf) { char url[FILENAME_MAX]; sprintf(url, "https://" TIC_HOST "/play?cart=%i", item->id); - fsOpenSystemPath(surf->fs, url); + openSystemPath(url); } } #endif