this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

File Sytem refactoring

Nesbox a39a206b 46edc3a6

+364 -448
+3 -3
src/studio/config.c
··· 337 337 { 338 338 s32 size = tic_cart_save(&config->cart, buffer); 339 339 340 - fsSaveRootFile(config->fs, CONFIG_TIC_PATH, buffer, size, overwrite); 340 + tic_fs_saveroot(config->fs, CONFIG_TIC_PATH, buffer, size, overwrite); 341 341 342 342 free(buffer); 343 343 } ··· 358 358 studioConfigChanged(); 359 359 } 360 360 361 - void initConfig(Config* config, tic_mem* tic, FileSystem* fs) 361 + void initConfig(Config* config, tic_mem* tic, tic_fs* fs) 362 362 { 363 363 { 364 364 config->tic = tic; ··· 370 370 setDefault(config); 371 371 372 372 s32 size = 0; 373 - u8* data = (u8*)fsLoadRootFile(fs, CONFIG_TIC_PATH, &size); 373 + u8* data = (u8*)tic_fs_loadroot(fs, CONFIG_TIC_PATH, &size); 374 374 375 375 if(data) 376 376 {
+2 -2
src/studio/config.h
··· 29 29 struct Config 30 30 { 31 31 tic_mem* tic; 32 - struct FileSystem* fs; 32 + struct tic_fs* fs; 33 33 34 34 StudioConfig data; 35 35 tic_cartridge cart; ··· 38 38 void(*reset)(Config*); 39 39 }; 40 40 41 - void initConfig(Config* config, tic_mem* tic, struct FileSystem* fs); 41 + void initConfig(Config* config, tic_mem* tic, struct tic_fs* fs); 42 42 void freeConfig(Config* config);
+106 -199
src/studio/fs.c
··· 57 57 58 58 static const char* PublicDir = TIC_HOST; 59 59 60 - struct FileSystem 60 + struct tic_fs 61 61 { 62 62 char dir[TICNAME_MAX]; 63 63 char work[TICNAME_MAX]; 64 - Net* net; 64 + tic_net* net; 65 65 }; 66 66 67 67 #if defined(__EMSCRIPTEN__) ··· 71 71 } 72 72 #endif 73 73 74 - const char* fsGetRootFilePath(FileSystem* fs, const char* name) 74 + const char* tic_fs_pathroot(tic_fs* fs, const char* name) 75 75 { 76 76 static char path[TICNAME_MAX]; 77 77 ··· 89 89 return path; 90 90 } 91 91 92 - const char* fsGetFilePath(FileSystem* fs, const char* name) 92 + const char* tic_fs_path(tic_fs* fs, const char* name) 93 93 { 94 94 static char path[TICNAME_MAX]; 95 95 ··· 100 100 else 101 101 strcpy(path, name); 102 102 103 - return fsGetRootFilePath(fs, path); 103 + return tic_fs_pathroot(fs, path); 104 104 } 105 105 106 - static bool isRoot(FileSystem* fs) 106 + static bool isRoot(tic_fs* fs) 107 107 { 108 108 return fs->work[0] == '\0'; 109 109 } 110 110 111 - static bool isPublicRoot(FileSystem* fs) 111 + static bool isPublicRoot(tic_fs* fs) 112 112 { 113 113 return strcmp(fs->work, PublicDir) == 0; 114 114 } 115 115 116 - static bool isPublic(FileSystem* fs) 116 + static bool isPublic(tic_fs* fs) 117 117 { 118 118 return memcmp(fs->work, PublicDir, sizeof PublicDir - 1) == 0; 119 119 } 120 120 121 - bool fsIsInPublicDir(FileSystem* fs) 121 + bool tic_fs_ispubdir(tic_fs* fs) 122 122 { 123 123 return isPublic(fs); 124 124 } ··· 196 196 197 197 typedef struct 198 198 { 199 - ListCallback item; 200 - DoneCallback done; 199 + fs_list_callback item; 200 + fs_done_callback done; 201 201 void* data; 202 202 } NetDirData; 203 203 ··· 224 224 return NULL; 225 225 } 226 226 227 - static void onDirResponse(const HttpGetData* netData) 227 + static void onDirResponse(const net_get_data* netData) 228 228 { 229 229 NetDirData* netDirData = (NetDirData*)netData->calldata; 230 230 231 - if(netData->type == HttpGetDone) 231 + if(netData->type == net_get_done) 232 232 { 233 233 lua_State* lua = netLuaInit(netData->done.data, netData->done.size); 234 234 ··· 313 313 314 314 switch (netData->type) 315 315 { 316 - case HttpGetDone: 317 - case HttpGetError: 316 + case net_get_done: 317 + case net_get_error: 318 318 netDirData->done(netDirData->data); 319 319 free(netDirData); 320 320 break; 321 321 } 322 322 } 323 323 324 - static void enumFiles(FileSystem* fs, const char* path, ListCallback callback, void* data, bool folder) 324 + static void enumFiles(tic_fs* fs, const char* path, fs_list_callback callback, void* data, bool folder) 325 325 { 326 326 #if defined(BAREMETALPI) 327 327 dbg("enumFiles %s", path); ··· 401 401 #endif 402 402 } 403 403 404 - void fsEnumFilesAsync(FileSystem* fs, ListCallback onItem, DoneCallback onDone, void* data) 404 + void tic_fs_enum(tic_fs* fs, fs_list_callback onItem, fs_done_callback onDone, void* data) 405 405 { 406 406 if (isRoot(fs) && !onItem(PublicDir, NULL, 0, data, true)) 407 407 { ··· 415 415 sprintf(request, "/api?fn=dir&path=%s", fs->work + sizeof(TIC_HOST)); 416 416 417 417 NetDirData netDirData = { onItem, onDone, data }; 418 - netGet(fs->net, request, onDirResponse, OBJCOPY(netDirData)); 418 + tic_net_get(fs->net, request, onDirResponse, OBJCOPY(netDirData)); 419 419 420 420 return; 421 421 } 422 422 423 - const char* path = fsGetFilePath(fs, ""); 423 + const char* path = tic_fs_path(fs, ""); 424 424 425 425 enumFiles(fs, path, onItem, data, true); 426 426 enumFiles(fs, path, onItem, data, false); ··· 428 428 onDone(data); 429 429 } 430 430 431 - bool fsDeleteDir(FileSystem* fs, const char* name) 431 + bool tic_fs_deldir(tic_fs* fs, const char* name) 432 432 { 433 433 #if defined(BAREMETALPI) 434 434 // TODO BAREMETALPI 435 - dbg("fsDeleteDir %s", name); 435 + dbg("tic_fs_deldir %s", name); 436 436 return 0; 437 437 #else 438 438 #if defined(__TIC_WINDOWS__) 439 - const char* path = fsGetFilePath(fs, name); 439 + const char* path = tic_fs_path(fs, name); 440 440 441 441 const FsString* pathString = utf8ToString(path); 442 442 bool result = tic_rmdir(pathString); 443 443 freeString(pathString); 444 444 445 445 #else 446 - bool result = rmdir(fsGetFilePath(fs, name)); 446 + bool result = rmdir(tic_fs_path(fs, name)); 447 447 #endif 448 448 449 449 #if defined(__EMSCRIPTEN__) ··· 454 454 #endif 455 455 } 456 456 457 - bool fsDeleteFile(FileSystem* fs, const char* name) 457 + bool tic_fs_delfile(tic_fs* fs, const char* name) 458 458 { 459 459 #if defined(BAREMETALPI) 460 - dbg("fsDeleteFile %s", name); 460 + dbg("tic_fs_delfile %s", name); 461 461 // TODO BAREMETALPI 462 462 return false; 463 463 #else 464 - const char* path = fsGetFilePath(fs, name); 464 + const char* path = tic_fs_path(fs, name); 465 465 466 466 const FsString* pathString = utf8ToString(path); 467 467 bool result = tic_remove(pathString); ··· 475 475 #endif 476 476 } 477 477 478 - void fsHomeDir(FileSystem* fs) 478 + void tic_fs_homedir(tic_fs* fs) 479 479 { 480 480 memset(fs->work, 0, sizeof fs->work); 481 481 } 482 482 483 - void fsDirBack(FileSystem* fs) 483 + void tic_fs_dirback(tic_fs* fs) 484 484 { 485 485 if(isPublicRoot(fs)) 486 486 { 487 - fsHomeDir(fs); 487 + tic_fs_homedir(fs); 488 488 return; 489 489 } 490 490 ··· 495 495 while (*ptr) *ptr++ = '\0'; 496 496 } 497 497 498 - void fsGetDir(FileSystem* fs, char* dir) 498 + void tic_fs_dir(tic_fs* fs, char* dir) 499 499 { 500 500 strcpy(dir, fs->work); 501 501 } 502 502 503 - void fsChangeDir(FileSystem* fs, const char* dir) 503 + void tic_fs_changedir(tic_fs* fs, const char* dir) 504 504 { 505 505 if(strlen(fs->work)) 506 506 strcat(fs->work, "/"); ··· 512 512 { 513 513 char* name; 514 514 bool found; 515 - IsDirCallback done; 515 + fs_isdir_callback done; 516 516 void* data; 517 517 518 518 } EnumPublicDirsData; ··· 538 538 free(enumPublicDirsData); 539 539 } 540 540 541 - bool fsIsDir(FileSystem* fs, const char* name) 541 + bool tic_fs_isdir(tic_fs* fs, const char* name) 542 542 { 543 543 if (*name == '.') return false; 544 544 if (isRoot(fs) && strcmp(name, PublicDir) == 0) return true; ··· 552 552 553 553 return s.fattrib & AM_DIR; 554 554 #else 555 - const char* path = fsGetFilePath(fs, name); 555 + const char* path = tic_fs_path(fs, name); 556 556 struct tic_stat_struct s; 557 557 const FsString* pathString = utf8ToString(path); 558 558 bool ret = tic_stat(pathString, &s) == 0 && S_ISDIR(s.st_mode); ··· 562 562 #endif 563 563 } 564 564 565 - void fsIsDirAsync(FileSystem* fs, const char* name, IsDirCallback callback, void* data) 565 + void tic_fs_isdir_async(tic_fs* fs, const char* name, fs_isdir_callback callback, void* data) 566 566 { 567 567 if(isPublicRoot(fs)) 568 568 { 569 569 EnumPublicDirsData enumPublicDirsData = { strdup(name), false, callback, data}; 570 - fsEnumFilesAsync(fs, onEnumPublicDirs, onEnumPublicDirsDone, OBJCOPY(enumPublicDirsData)); 570 + tic_fs_enum(fs, onEnumPublicDirs, onEnumPublicDirsDone, OBJCOPY(enumPublicDirsData)); 571 571 return; 572 572 } 573 573 574 - callback(fsIsDir(fs, name), data); 574 + callback(tic_fs_isdir(fs, name), data); 575 575 } 576 576 577 - bool fsWriteFile(const char* name, const void* buffer, s32 size) 577 + bool fs_write(const char* name, const void* buffer, s32 size) 578 578 { 579 579 #if defined(BAREMETALPI) 580 - dbg("fsWriteFile %s\n", name); 580 + dbg("fs_write %s\n", name); 581 581 FIL File; 582 582 FRESULT res = f_open (&File, name, FA_WRITE | FA_CREATE_ALWAYS); 583 583 if (res != FR_OK) ··· 621 621 #endif 622 622 } 623 623 624 - void* fsReadFile(const char* path, s32* size) 624 + void* fs_read(const char* path, s32* size) 625 625 { 626 626 #if defined(BAREMETALPI) 627 - dbg("fsReadFile %s\n", path); 627 + dbg("fs_read %s\n", path); 628 628 FILINFO fi; 629 629 FRESULT res = f_stat(path, &fi); 630 630 if(res!=FR_OK) return NULL; ··· 665 665 #endif 666 666 } 667 667 668 - static void makeDir(const char* name) 669 - { 670 - #if defined(BAREMETALPI) 671 - // TODO BAREMETALPI 672 - dbg("makeDir %s\n", name); 673 - 674 - char* path = strdup(name); 675 - if (path && *path) { // make sure result has at least 676 - if (path[strlen(path) - 1] == '/') // one character 677 - path[strlen(path) - 1] = 0; 678 - } 679 - 680 - FRESULT res = f_mkdir(path); 681 - if(res != FR_OK) 682 - { 683 - dbg("Could not mkdir %s\n", name); 684 - } 685 - free(path); 686 - #else 687 - const FsString* pathString = utf8ToString(name); 688 - tic_mkdir(pathString); 689 - freeString(pathString); 690 - 691 - #if defined(__EMSCRIPTEN__) 692 - syncfs(); 693 - #endif 694 - #endif 695 - } 696 - 697 - static void fsFullname(const char *path, char *fullname) 698 - { 699 - #if defined(BAREMETALPI) || defined(_3DS) 700 - dbg("fsFullname %s", path); 701 - // TODO BAREMETALPI 702 - #else 703 - #if defined(__TIC_WINDOWS__) 704 - static wchar_t wpath[TICNAME_MAX]; 705 - 706 - const FsString* pathString = utf8ToString(path); 707 - GetFullPathNameW(pathString, sizeof(wpath), wpath, NULL); 708 - freeString(pathString); 709 - 710 - const char* res = stringToUtf8(wpath); 711 - 712 - #else 713 - 714 - const char* res = realpath(path, NULL); 715 - 716 - #endif 717 - 718 - strcpy(fullname, res); 719 - free((void*)res); 720 - #endif 721 - } 722 - 723 - void fsFilename(const char *path, char* out) 724 - { 725 - char full[TICNAME_MAX]; 726 - fsFullname(path, full); 727 - 728 - char base[TICNAME_MAX]; 729 - fsBasename(path, base); 730 - 731 - strcpy(out, full + strlen(base)); 732 - } 733 - 734 - void fsBasename(const char *path, char* out) 668 + bool fs_exists(const char* name) 735 669 { 736 670 #if defined(BAREMETALPI) 737 - // TODO BAREMETALPI 738 - dbg("fsBasename %s\n", path); 739 - #define SEP "/" 740 - #else 741 - 742 - char* result = NULL; 743 - 744 - #if defined(__TIC_WINDOWS__) 745 - #define SEP "\\" 746 - #else 747 - #define SEP "/" 748 - #endif 749 - 750 - 751 - char full[TICNAME_MAX]; 752 - fsFullname(path, full); 753 - 754 - struct tic_stat_struct s; 755 - 756 - const FsString* fullString = utf8ToString(full); 757 - s32 ret = tic_stat(fullString, &s); 758 - freeString(fullString); 759 - 760 - if(ret == 0) 761 - { 762 - result = full; 763 - 764 - if(S_ISREG(s.st_mode)) 765 - { 766 - const char* ptr = result + strlen(result); 767 - 768 - while(ptr >= result) 769 - { 770 - if(*ptr == SEP[0]) 771 - { 772 - result[ptr-result] = '\0'; 773 - break; 774 - } 775 - 776 - ptr--; 777 - } 778 - } 779 - } 780 - 781 - if (result) 782 - { 783 - if (result[strlen(result) - 1] != SEP[0]) 784 - strcat(result, SEP); 785 - 786 - strcpy(out, result); 787 - } 788 - #endif 789 - } 790 - 791 - bool fsExists(const char* name) 792 - { 793 - #if defined(BAREMETALPI) 794 - dbg("fsExists %s\n", name); 671 + dbg("fs_exists %s\n", name); 795 672 FILINFO s; 796 673 797 674 FRESULT res = f_stat(name, &s); ··· 807 684 #endif 808 685 } 809 686 810 - bool fsExistsFile(FileSystem* fs, const char* name) 687 + bool tic_fs_exists(tic_fs* fs, const char* name) 811 688 { 812 - return fsExists(fsGetFilePath(fs, name)); 689 + return fs_exists(tic_fs_path(fs, name)); 813 690 } 814 691 815 - u64 fsMDate(const char* path) 692 + u64 fs_date(const char* path) 816 693 { 817 694 #if defined(BAREMETALPI) 818 - dbg("fsMDate %s\n", path); 695 + dbg("fs_date %s\n", path); 819 696 // TODO BAREMETALPI 820 697 return 0; 821 698 #else ··· 834 711 #endif 835 712 } 836 713 837 - bool fsSaveFile(FileSystem* fs, const char* name, const void* data, s32 size, bool overwrite) 714 + bool tic_fs_save(tic_fs* fs, const char* name, const void* data, s32 size, bool overwrite) 838 715 { 839 716 if(!overwrite) 840 717 { 841 - if(fsExistsFile(fs, name)) 718 + if(tic_fs_exists(fs, name)) 842 719 return false; 843 720 } 844 721 845 - return fsWriteFile(fsGetFilePath(fs, name), data, size); 722 + return fs_write(tic_fs_path(fs, name), data, size); 846 723 } 847 724 848 - bool fsSaveRootFile(FileSystem* fs, const char* name, const void* data, s32 size, bool overwrite) 725 + bool tic_fs_saveroot(tic_fs* fs, const char* name, const void* data, s32 size, bool overwrite) 849 726 { 850 - const char* path = fsGetRootFilePath(fs, name); 727 + const char* path = tic_fs_pathroot(fs, name); 851 728 852 729 if(!overwrite) 853 730 { 854 - if(fsExists(path)) 731 + if(fs_exists(path)) 855 732 return false; 856 733 } 857 734 858 - return fsWriteFile(path, data, size); 735 + return fs_write(path, data, size); 859 736 } 860 737 861 738 typedef struct 862 739 { 863 - FileSystem* fs; 864 - LoadCallback done; 740 + tic_fs* fs; 741 + fs_load_callback done; 865 742 void* data; 866 743 char* cachePath; 867 744 } LoadFileByHashData; 868 745 869 - static void fileByHashLoaded(const HttpGetData* netData) 746 + static void fileByHashLoaded(const net_get_data* netData) 870 747 { 871 748 LoadFileByHashData* loadFileByHashData = netData->calldata; 872 749 873 - if (netData->type == HttpGetDone) 750 + if (netData->type == net_get_done) 874 751 { 875 - fsSaveRootFile(loadFileByHashData->fs, loadFileByHashData->cachePath, netData->done.data, netData->done.size, false); 752 + tic_fs_saveroot(loadFileByHashData->fs, loadFileByHashData->cachePath, netData->done.data, netData->done.size, false); 876 753 loadFileByHashData->done(netData->done.data, netData->done.size, loadFileByHashData->data); 877 754 } 878 755 879 756 switch (netData->type) 880 757 { 881 - case HttpGetDone: 882 - case HttpGetError: 758 + case net_get_done: 759 + case net_get_error: 883 760 884 761 free(loadFileByHashData->cachePath); 885 762 free(loadFileByHashData); ··· 887 764 } 888 765 } 889 766 890 - void fsLoadFileByHashAsync(FileSystem* fs, const char* hash, LoadCallback callback, void* data) 767 + void tic_fs_hashload(tic_fs* fs, const char* hash, fs_load_callback callback, void* data) 891 768 { 892 769 #if defined(BAREMETALPI) 893 770 // TODO BAREMETALPI ··· 899 776 900 777 { 901 778 s32 size = 0; 902 - void* buffer = fsLoadRootFile(fs, cachePath, &size); 779 + void* buffer = tic_fs_loadroot(fs, cachePath, &size); 903 780 if (buffer) 904 781 { 905 782 callback(buffer, size, data); ··· 911 788 sprintf(path, "/cart/%s/cart.tic", hash); 912 789 913 790 LoadFileByHashData loadFileByHashData = { fs, callback, data, strdup(cachePath) }; 914 - netGet(fs->net, path, fileByHashLoaded, OBJCOPY(loadFileByHashData)); 791 + tic_net_get(fs->net, path, fileByHashLoaded, OBJCOPY(loadFileByHashData)); 915 792 #endif 916 793 } 917 794 918 - void* fsLoadFile(FileSystem* fs, const char* name, s32* size) 795 + void* tic_fs_load(tic_fs* fs, const char* name, s32* size) 919 796 { 920 797 #if defined(BAREMETALPI) 921 - dbg("fsLoadFile x %s\n", name); 798 + dbg("tic_fs_load x %s\n", name); 922 799 dbg("fs.dir %s\n", fs->dir); 923 800 dbg("fs.work %s\n", fs->work); 924 801 ··· 930 807 else 931 808 { 932 809 dbg("non public \n"); 933 - const char* fp = fsGetFilePath(fs, name); 810 + const char* fp = tic_fs_path(fs, name); 934 811 dbg("loading: %s\n", fp); 935 812 936 813 ··· 972 849 return NULL; 973 850 #else 974 851 975 - const FsString* pathString = utf8ToString(fsGetFilePath(fs, name)); 852 + const FsString* pathString = utf8ToString(tic_fs_path(fs, name)); 976 853 FILE* file = tic_fopen(pathString, _S("rb")); 977 854 freeString(pathString); 978 855 ··· 996 873 #endif 997 874 } 998 875 999 - void* fsLoadRootFile(FileSystem* fs, const char* name, s32* size) 876 + void* tic_fs_loadroot(tic_fs* fs, const char* name, s32* size) 1000 877 { 1001 - return fsReadFile(fsGetRootFilePath(fs, name), size); 878 + return fs_read(tic_fs_pathroot(fs, name), size); 1002 879 } 1003 880 1004 - void fsMakeDir(FileSystem* fs, const char* name) 881 + void tic_fs_makedir(tic_fs* fs, const char* name) 1005 882 { 1006 - makeDir(fsGetFilePath(fs, name)); 883 + #if defined(BAREMETALPI) 884 + // TODO BAREMETALPI 885 + dbg("makeDir %s\n", name); 886 + 887 + char* path = strdup(name); 888 + if (path && *path) { // make sure result has at least 889 + if (path[strlen(path) - 1] == '/') // one character 890 + path[strlen(path) - 1] = 0; 891 + } 892 + 893 + FRESULT res = f_mkdir(path); 894 + if(res != FR_OK) 895 + { 896 + dbg("Could not mkdir %s\n", name); 897 + } 898 + free(path); 899 + #else 900 + const FsString* pathString = utf8ToString(name); 901 + tic_mkdir(pathString); 902 + freeString(pathString); 903 + 904 + #if defined(__EMSCRIPTEN__) 905 + syncfs(); 906 + #endif 907 + #endif 1007 908 } 1008 909 1009 - void fsOpenWorkingFolder(FileSystem* fs) 910 + void tic_fs_openfolder(tic_fs* fs) 1010 911 { 1011 - const char* path = fsGetFilePath(fs, ""); 912 + const char* path = tic_fs_path(fs, ""); 1012 913 1013 914 if(isPublic(fs)) 1014 915 path = fs->dir; ··· 1016 917 tic_sys_open_path(path); 1017 918 } 1018 919 1019 - FileSystem* createFileSystem(const char* path, Net* net) 920 + #if defined(__TIC_WINDOWS__) 921 + #define SEP "\\" 922 + #else 923 + #define SEP "/" 924 + #endif 925 + 926 + tic_fs* tic_fs_create(const char* path, tic_net* net) 1020 927 { 1021 - FileSystem* fs = (FileSystem*)calloc(1, sizeof(FileSystem)); 928 + tic_fs* fs = (tic_fs*)calloc(1, sizeof(tic_fs)); 1022 929 1023 930 strcpy(fs->dir, path); 1024 931
+31 -34
src/studio/fs.h
··· 25 25 #include <tic80_types.h> 26 26 #include <string.h> 27 27 28 - typedef bool(*ListCallback)(const char* name, const char* info, s32 id, void* data, bool dir); 29 - typedef void(*DoneCallback)(void* data); 30 - typedef void(*IsDirCallback)(bool dir, void* data); 31 - typedef void(*LoadCallback)(const u8* buffer, s32 size, void* data); 28 + typedef bool(*fs_list_callback)(const char* name, const char* info, s32 id, void* data, bool dir); 29 + typedef void(*fs_done_callback)(void* data); 30 + typedef void(*fs_isdir_callback)(bool dir, void* data); 31 + typedef void(*fs_load_callback)(const u8* buffer, s32 size, void* data); 32 32 33 - typedef struct FileSystem FileSystem; 34 - struct Net; 33 + typedef struct tic_fs tic_fs; 34 + struct tic_net; 35 35 36 - FileSystem* createFileSystem(const char* path, struct Net* net); 36 + tic_fs* tic_fs_create (const char* path, struct tic_net* net); 37 + const char* tic_fs_path (tic_fs* fs, const char* name); 38 + const char* tic_fs_pathroot (tic_fs* fs, const char* name); 37 39 38 - void fsEnumFilesAsync(FileSystem* fs, ListCallback onItem, DoneCallback onDone, void* data); 39 - void fsIsDirAsync(FileSystem* fs, const char* name, IsDirCallback callback, void* data); 40 - void fsLoadFileByHashAsync(FileSystem* fs, const char* hash, LoadCallback callback, void* data); 41 - 42 - bool fsDeleteFile(FileSystem* fs, const char* name); 43 - bool fsDeleteDir(FileSystem* fs, const char* name); 44 - bool fsSaveFile(FileSystem* fs, const char* name, const void* data, s32 size, bool overwrite); 45 - bool fsSaveRootFile(FileSystem* fs, const char* name, const void* data, s32 size, bool overwrite); 46 - void* fsLoadFile(FileSystem* fs, const char* name, s32* size); 47 - void* fsLoadRootFile(FileSystem* fs, const char* name, s32* size); 48 - const char* fsGetFilePath(FileSystem* fs, const char* name); 49 - const char* fsGetRootFilePath(FileSystem* fs, const char* name); 50 - void fsMakeDir(FileSystem* fs, const char* name); 51 - bool fsExistsFile(FileSystem* fs, const char* name); 40 + void tic_fs_enum (tic_fs* fs, fs_list_callback onItem, fs_done_callback onDone, void* data); 41 + void tic_fs_isdir_async (tic_fs* fs, const char* name, fs_isdir_callback callback, void* data); 42 + void tic_fs_hashload (tic_fs* fs, const char* hash, fs_load_callback callback, void* data); 43 + bool tic_fs_delfile (tic_fs* fs, const char* name); 44 + bool tic_fs_deldir (tic_fs* fs, const char* name); 45 + bool tic_fs_save (tic_fs* fs, const char* name, const void* data, s32 size, bool overwrite); 46 + bool tic_fs_saveroot (tic_fs* fs, const char* name, const void* data, s32 size, bool overwrite); 47 + void* tic_fs_load (tic_fs* fs, const char* name, s32* size); 48 + void* tic_fs_loadroot (tic_fs* fs, const char* name, s32* size); 49 + void tic_fs_makedir (tic_fs* fs, const char* name); 50 + bool tic_fs_exists (tic_fs* fs, const char* name); 51 + void tic_fs_openfolder (tic_fs* fs); 52 + bool tic_fs_isdir (tic_fs* fs, const char* dir); 53 + bool tic_fs_ispubdir (tic_fs* fs); 54 + void tic_fs_changedir (tic_fs* fs, const char* dir); 55 + void tic_fs_dir (tic_fs* fs, char* out); 56 + void tic_fs_dirback (tic_fs* fs); 57 + void tic_fs_homedir (tic_fs* fs); 52 58 53 - u64 fsMDate(const char* name); 54 - void fsBasename(const char *path, char* out); 55 - void fsFilename(const char *path, char* out); 56 - bool fsExists(const char* name); 57 - void* fsReadFile(const char* path, s32* size); 58 - bool fsWriteFile(const char* path, const void* data, s32 size); 59 - void fsOpenWorkingFolder(FileSystem* fs); 60 - bool fsIsDir(FileSystem* fs, const char* dir); 61 - bool fsIsInPublicDir(FileSystem* fs); 62 - void fsChangeDir(FileSystem* fs, const char* dir); 63 - void fsGetDir(FileSystem* fs, char* out); 64 - void fsDirBack(FileSystem* fs); 65 - void fsHomeDir(FileSystem* fs); 59 + u64 fs_date (const char* name); 60 + bool fs_exists (const char* name); 61 + void* fs_read (const char* path, s32* size); 62 + bool fs_write (const char* path, const void* data, s32 size);
+74 -74
src/studio/net.c
··· 35 35 36 36 typedef struct 37 37 { 38 - HttpGetCallback callback; 38 + net_get_callback callback; 39 39 void* calldata; 40 40 } FetchData; 41 41 42 - struct Net 42 + struct tic_net 43 43 { 44 44 emscripten_fetch_attr_t attr; 45 45 }; ··· 48 48 { 49 49 FetchData* data = (FetchData*)fetch->userData; 50 50 51 - HttpGetData getData = 51 + net_get_data getData = 52 52 { 53 - .type = HttpGetDone, 53 + .type = net_get_done, 54 54 .done = 55 55 { 56 56 .size = fetch->numBytes, ··· 72 72 { 73 73 FetchData* data = (FetchData*)fetch->userData; 74 74 75 - HttpGetData getData = 75 + net_get_data getData = 76 76 { 77 - .type = HttpGetError, 77 + .type = net_get_error, 78 78 .error = 79 79 { 80 80 .code = fetch->status, ··· 94 94 { 95 95 FetchData* data = (FetchData*)fetch->userData; 96 96 97 - HttpGetData getData = 97 + net_get_data getData = 98 98 { 99 - .type = HttpGetProgress, 99 + .type = net_get_progress, 100 100 .progress = 101 101 { 102 102 .size = fetch->dataOffset + fetch->numBytes, ··· 109 109 data->callback(&getData); 110 110 } 111 111 112 - void netGet(Net* net, const char* path, HttpGetCallback callback, void* calldata) 112 + void tic_net_get(tic_net* net, const char* path, net_get_callback callback, void* calldata) 113 113 { 114 114 FetchData* data = calloc(1, sizeof(FetchData)); 115 115 *data = (FetchData) ··· 122 122 emscripten_fetch(&net->attr, path); 123 123 } 124 124 125 - void netTickStart(Net *net) {} 126 - void netTickEnd(Net *net) {} 125 + void tic_net_start(tic_net *net) {} 126 + void tic_net_end(tic_net *net) {} 127 127 128 - Net* netCreate(const char* host) 128 + tic_net* tic_net_create(const char* host) 129 129 { 130 - Net* net = (Net*)malloc(sizeof(Net)); 130 + tic_net* net = (tic_net*)malloc(sizeof(tic_net)); 131 131 132 132 emscripten_fetch_attr_init(&net->attr); 133 133 strcpy(net->attr.requestMethod, "GET"); ··· 139 139 return net; 140 140 } 141 141 142 - void netClose(Net* net) 142 + void tic_net_close(tic_net* net) 143 143 { 144 144 free(net); 145 145 } ··· 148 148 149 149 #include <3ds.h> 150 150 151 - struct Net 151 + struct tic_net 152 152 { 153 153 LightLock tick_lock; 154 154 const char* host; ··· 157 157 typedef struct { 158 158 char url[URL_SIZE]; 159 159 160 - Net *net; 160 + tic_net *net; 161 161 httpcContext httpc; 162 - HttpGetData data; 163 - HttpGetCallback callback; 162 + net_get_data data; 163 + net_get_callback callback; 164 164 165 165 void *buffer; 166 166 s32 size; ··· 202 202 if (status_code != 200) { \ 203 203 printf("net_httpc: error %d\n", status_code); \ 204 204 if (ctx->callback != NULL) { \ 205 - ctx->data.type = HttpGetError; \ 205 + ctx->data.type = net_get_error; \ 206 206 ctx->data.error.code = status_code; \ 207 207 if (!ignore_lock) LightLock_Lock(&ctx->net->tick_lock); \ 208 208 ctx->callback(&ctx->data); \ ··· 267 267 ctx_resize_buf(ctx, old_size + read_size); 268 268 if (ctx->callback != NULL) { 269 269 if (ignore_lock || !LightLock_TryLock(&ctx->net->tick_lock)) { 270 - ctx->data.type = HttpGetProgress; 270 + ctx->data.type = net_get_progress; 271 271 if (!httpcGetDownloadSizeState(&ctx->httpc, &ctx->data.progress.size, &ctx->data.progress.total)) { 272 272 if (ctx->data.progress.total < ctx->data.progress.size) { 273 273 ctx->data.progress.total = ctx->data.progress.size; ··· 290 290 NET_EXEC_ERROR_CHECK; 291 291 292 292 if (ctx->callback != NULL) { 293 - ctx->data.type = HttpGetDone; 293 + ctx->data.type = net_get_done; 294 294 ctx->data.done.data = ctx->buffer; 295 295 ctx->data.done.size = ctx->size; 296 296 if (!ignore_lock) LightLock_Lock(&ctx->net->tick_lock); ··· 300 300 httpcCloseContext(&ctx->httpc); 301 301 } 302 302 303 - static void n3ds_net_init(Net *net) { 303 + static void n3ds_net_init(tic_net *net) { 304 304 httpcInit(0); 305 305 306 - memset(net, 0, sizeof(Net)); 306 + memset(net, 0, sizeof(tic_net)); 307 307 LightLock_Init(&net->tick_lock); 308 308 } 309 309 310 - static void n3ds_net_free(Net *net) { 310 + static void n3ds_net_free(tic_net *net) { 311 311 httpcExit(); 312 312 } 313 313 ··· 325 325 strncat(ctx->url, url, URL_SIZE - 1); 326 326 } 327 327 328 - static void n3ds_net_get(Net *net, const char *url, HttpGetCallback callback, void *calldata) { 328 + static void n3ds_net_get(tic_net *net, const char *url, net_get_callback callback, void *calldata) { 329 329 s32 priority; 330 330 net_ctx *ctx; 331 331 ··· 341 341 threadCreate((ThreadFunc) n3ds_net_get_thread, ctx, 16 * 1024, priority - 1, -1, true); 342 342 } 343 343 344 - Net* netCreate(const char* host) 344 + tic_net* tic_net_create(const char* host) 345 345 { 346 - Net* net = (Net*)malloc(sizeof(Net)); 346 + tic_net* net = (tic_net*)malloc(sizeof(tic_net)); 347 347 348 348 n3ds_net_init(net); 349 349 net->host = host; ··· 351 351 return net; 352 352 } 353 353 354 - void netGet(Net* net, const char* url, HttpGetCallback callback, void* calldata) 354 + void tic_net_get(tic_net* net, const char* url, net_get_callback callback, void* calldata) 355 355 { 356 356 n3ds_net_get(net, url, callback, calldata); 357 357 } 358 358 359 - void netClose(Net* net) 359 + void tic_net_close(tic_net* net) 360 360 { 361 361 n3ds_net_free(net); 362 362 free(net); 363 363 } 364 364 365 - void netTickStart(Net *net) 365 + void tic_net_start(tic_net *net) 366 366 { 367 367 LightLock_Lock(&net->tick_lock); 368 368 } 369 369 370 - void netTickEnd(Net *net) 370 + void tic_net_end(tic_net *net) 371 371 { 372 372 LightLock_Unlock(&net->tick_lock); 373 373 } 374 374 375 375 #elif defined(BAREMETALPI) 376 376 377 - Net* netCreate(const char* host) {return NULL;} 378 - void netGet(Net* net, const char* url, HttpGetCallback callback, void* calldata) {} 379 - void netClose(Net* net) {} 380 - void netTickStart(Net *net) {} 381 - void netTickEnd(Net *net) {} 377 + tic_net* tic_net_create(const char* host) {return NULL;} 378 + void tic_net_get(tic_net* net, const char* url, net_get_callback callback, void* calldata) {} 379 + void tic_net_close(tic_net* net) {} 380 + void tic_net_start(tic_net *net) {} 381 + void tic_net_end(tic_net *net) {} 382 382 383 383 #elif defined(USE_LIBUV) 384 384 ··· 387 387 #include <uv.h> 388 388 #include <http_parser.h> 389 389 390 - struct Net 390 + struct tic_net 391 391 { 392 392 const char* host; 393 393 char* path; 394 394 395 - HttpGetCallback callback; 395 + net_get_callback callback; 396 396 void* calldata; 397 397 398 398 uv_tcp_t tcp; ··· 408 408 409 409 static s32 onBody(http_parser* parser, const char *at, size_t length) 410 410 { 411 - Net* net = parser->data; 411 + tic_net* net = parser->data; 412 412 413 413 net->content.data = realloc(net->content.data, net->content.size + length); 414 414 memcpy(net->content.data + net->content.size, at, length); 415 415 416 416 net->content.size += length; 417 417 418 - net->callback(&(HttpGetData) 418 + net->callback(&(net_get_data) 419 419 { 420 420 .calldata = net->calldata, 421 - .type = HttpGetProgress, 421 + .type = net_get_progress, 422 422 .progress = {net->content.size, net->content.total}, 423 423 .url = net->path 424 424 }); ··· 428 428 429 429 static s32 onMessageComplete(http_parser* parser) 430 430 { 431 - Net* net = parser->data; 431 + tic_net* net = parser->data; 432 432 433 433 if (parser->status_code == HTTP_STATUS_OK) 434 434 { 435 - net->callback(&(HttpGetData) 435 + net->callback(&(net_get_data) 436 436 { 437 437 .calldata = net->calldata, 438 - .type = HttpGetDone, 438 + .type = net_get_done, 439 439 .done = { .data = net->content.data, .size = net->content.size }, 440 440 .url = net->path 441 441 }); ··· 451 451 452 452 static s32 onHeadersComplete(http_parser* parser) 453 453 { 454 - Net* net = parser->data; 454 + tic_net* net = parser->data; 455 455 456 456 bool hasBody = parser->flags & F_CHUNKED || (parser->content_length > 0 && parser->content_length != ULLONG_MAX); 457 457 ··· 470 470 return parser->status_code != HTTP_STATUS_OK; 471 471 } 472 472 473 - static void onError(Net* net, s32 code) 473 + static void onError(tic_net* net, s32 code) 474 474 { 475 - net->callback(&(HttpGetData) 475 + net->callback(&(net_get_data) 476 476 { 477 477 .calldata = net->calldata, 478 - .type = HttpGetError, 478 + .type = net_get_error, 479 479 .error = { .code = code } 480 480 }); 481 481 ··· 491 491 492 492 static void onResponse(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) 493 493 { 494 - Net* net = stream->data; 494 + tic_net* net = stream->data; 495 495 496 496 if(nread > 0) 497 497 { ··· 515 515 516 516 static void onHeaderSent(uv_write_t *write, s32 status) 517 517 { 518 - Net* net = write->data; 518 + tic_net* net = write->data; 519 519 http_parser_init(&net->parser, HTTP_RESPONSE); 520 520 net->parser.data = net; 521 521 ··· 529 529 530 530 static void onConnect(uv_connect_t *req, s32 status) 531 531 { 532 - Net* net = req->data; 532 + tic_net* net = req->data; 533 533 534 534 char httpReq[2048]; 535 535 snprintf(httpReq, sizeof httpReq, "GET %s HTTP/1.1\nHost: %s\n\n", net->path, net->host); ··· 542 542 543 543 static void onResolved(uv_getaddrinfo_t *resolver, s32 status, struct addrinfo *res) 544 544 { 545 - Net* net = resolver->data; 545 + tic_net* net = resolver->data; 546 546 547 547 if (res) 548 548 { ··· 554 554 free(resolver); 555 555 } 556 556 557 - void netGet(Net* net, const char* path, HttpGetCallback callback, void* calldata) 557 + void tic_net_get(tic_net* net, const char* path, net_get_callback callback, void* calldata) 558 558 { 559 559 uv_loop_t* loop = uv_default_loop(); 560 560 ··· 566 566 uv_getaddrinfo(loop, OBJCOPY((uv_getaddrinfo_t){.data = net}), onResolved, net->host, "80", NULL); 567 567 } 568 568 569 - void netTickStart(Net *net) 569 + void tic_net_start(tic_net *net) 570 570 { 571 571 uv_run(uv_default_loop(), UV_RUN_NOWAIT); 572 572 } 573 573 574 - void netTickEnd(Net *net) {} 574 + void tic_net_end(tic_net *net) {} 575 575 576 - Net* netCreate(const char* host) 576 + tic_net* tic_net_create(const char* host) 577 577 { 578 - Net* net = (Net*)malloc(sizeof(Net)); 579 - memset(net, 0, sizeof(Net)); 578 + tic_net* net = (tic_net*)malloc(sizeof(tic_net)); 579 + memset(net, 0, sizeof(tic_net)); 580 580 581 581 net->host = host; 582 582 ··· 587 587 return net; 588 588 } 589 589 590 - void netClose(Net* net) 590 + void tic_net_close(tic_net* net) 591 591 { 592 592 free(net); 593 593 } ··· 602 602 s32 size; 603 603 604 604 struct Curl_easy* async; 605 - HttpGetCallback callback; 605 + net_get_callback callback; 606 606 void* calldata; 607 607 char url[URL_SIZE]; 608 608 } CurlData; 609 609 610 - struct Net 610 + struct tic_net 611 611 { 612 612 const char* host; 613 613 CURLM* multi; ··· 651 651 652 652 if(cl > 0.0) 653 653 { 654 - HttpGetData getData = 654 + net_get_data getData = 655 655 { 656 - .type = HttpGetProgress, 656 + .type = net_get_progress, 657 657 .progress = 658 658 { 659 659 .size = data->size, ··· 669 669 return total; 670 670 } 671 671 672 - void netGet(Net* net, const char* path, HttpGetCallback callback, void* calldata) 672 + void tic_net_get(tic_net* net, const char* path, net_get_callback callback, void* calldata) 673 673 { 674 674 struct Curl_easy* curl = curl_easy_init(); 675 675 ··· 697 697 } 698 698 } 699 699 700 - void netTickStart(Net *net) 700 + void tic_net_start(tic_net *net) 701 701 { 702 702 { 703 703 s32 running = 0; ··· 719 719 720 720 if(httpCode == 200) 721 721 { 722 - HttpGetData getData = 722 + net_get_data getData = 723 723 { 724 - .type = HttpGetDone, 724 + .type = net_get_done, 725 725 .done = 726 726 { 727 727 .size = data->size, ··· 737 737 } 738 738 else 739 739 { 740 - HttpGetData getData = 740 + net_get_data getData = 741 741 { 742 - .type = HttpGetError, 742 + .type = net_get_error, 743 743 .error = 744 744 { 745 745 .code = httpCode, ··· 759 759 } 760 760 } 761 761 762 - void netTickEnd(Net *net) {} 762 + void tic_net_end(tic_net *net) {} 763 763 764 - Net* netCreate(const char* host) 764 + tic_net* tic_net_create(const char* host) 765 765 { 766 - Net* net = (Net*)malloc(sizeof(Net)); 766 + tic_net* net = (tic_net*)malloc(sizeof(tic_net)); 767 767 768 768 if (net != NULL) 769 769 { 770 - *net = (Net) 770 + *net = (tic_net) 771 771 { 772 772 .multi = curl_multi_init(), 773 773 .host = host, ··· 777 777 return net; 778 778 } 779 779 780 - void netClose(Net* net) 780 + void tic_net_close(tic_net* net) 781 781 { 782 782 if(net->multi) 783 783 curl_multi_cleanup(net->multi);
+12 -11
src/studio/net.h
··· 24 24 25 25 #include "tic80_types.h" 26 26 27 - typedef struct Net Net; 27 + typedef struct tic_net tic_net; 28 28 29 29 typedef struct 30 30 { 31 31 enum 32 32 { 33 - HttpGetProgress, 34 - HttpGetDone, 35 - HttpGetError, 33 + net_get_progress, 34 + net_get_done, 35 + net_get_error, 36 36 } type; 37 37 38 38 union ··· 58 58 void* calldata; 59 59 const char* url; 60 60 61 - } HttpGetData; 61 + } net_get_data; 62 62 63 - typedef void(*HttpGetCallback)(const HttpGetData*); 63 + typedef void(*net_get_callback)(const net_get_data*); 64 64 65 - Net* netCreate(const char* host); 66 - void netGet(Net* net, const char* url, HttpGetCallback callback, void* calldata); 67 - void netClose(Net* net); 68 - void netTickStart(Net *net); 69 - void netTickEnd(Net *net); 65 + tic_net* tic_net_create(const char* host); 66 + 67 + void tic_net_get(tic_net* net, const char* url, net_get_callback callback, void* calldata); 68 + void tic_net_close(tic_net* net); 69 + void tic_net_start(tic_net *net); 70 + void tic_net_end(tic_net *net);
+82 -71
src/studio/screens/console.c
··· 224 224 printLine(console); 225 225 226 226 char dir[TICNAME_MAX]; 227 - fsGetDir(console->fs, dir); 227 + tic_fs_dir(console->fs, dir); 228 228 if(strlen(dir)) 229 229 printBack(console, dir); 230 230 ··· 406 406 pos[sizeof(CART_EXT) - 1] = 0; 407 407 const char* name = getCartName(param); 408 408 s32 size = 0; 409 - void* data = fsLoadFile(console->fs, name, &size); 409 + void* data = tic_fs_load(console->fs, name, &size); 410 410 411 411 if(data) 412 412 { ··· 486 486 #endif 487 487 } 488 488 489 - void* data = fsLoadRootFile(console->fs, path, size); 489 + void* data = tic_fs_loadroot(console->fs, path, size); 490 490 491 491 if(data && *size) 492 492 return data; ··· 591 591 *size = tic_tool_unzip(data, sizeof(tic_cartridge), demo, romSize); 592 592 593 593 if(*size) 594 - fsSaveRootFile(console->fs, path, data, *size, false); 594 + tic_fs_saveroot(console->fs, path, data, *size, false); 595 595 } 596 596 597 597 return data; ··· 643 643 644 644 const char* name = getCartName(param); 645 645 646 - setCartName(console, name, fsGetFilePath(console->fs, name)); 646 + setCartName(console, name, tic_fs_path(console->fs, name)); 647 647 648 648 loadRom(console->tic, data, size); 649 649 ··· 658 658 659 659 static void onCartLoaded(Console* console, const char* name) 660 660 { 661 - setCartName(console, name, fsGetFilePath(console->fs, name)); 661 + setCartName(console, name, tic_fs_path(console->fs, name)); 662 662 663 663 studioRomLoaded(); 664 664 ··· 678 678 if(strlen(path) && hasProjectExt(path)) 679 679 { 680 680 s32 size = 0; 681 - void* data = fsReadFile(path, &size); 681 + void* data = fs_read(path, &size); 682 682 683 683 if(data) 684 684 { ··· 706 706 { 707 707 Console* console; 708 708 char* name; 709 - DoneCallback callback; 709 + fs_done_callback callback; 710 710 void* calldata; 711 711 }LoadByHashData; 712 712 ··· 729 729 commandDone(console); 730 730 } 731 731 732 - static void loadByHash(Console* console, const char* name, const char* hash, DoneCallback callback, void* data) 732 + static void loadByHash(Console* console, const char* name, const char* hash, fs_done_callback callback, void* data) 733 733 { 734 734 console->active = false; 735 735 736 736 LoadByHashData loadByHashData = { console, strdup(name), callback, data}; 737 - fsLoadFileByHashAsync(console->fs, hash, loadByHashDone, OBJCOPY(loadByHashData)); 737 + tic_fs_hashload(console->fs, hash, loadByHashDone, OBJCOPY(loadByHashData)); 738 738 } 739 739 740 740 typedef struct ··· 788 788 { 789 789 const char* name = getCartName(param); 790 790 791 - if (fsIsInPublicDir(console->fs)) 791 + if (tic_fs_ispubdir(console->fs)) 792 792 { 793 793 LoadPublicCartData loadPublicCartData = { console, strdup(name) }; 794 - fsEnumFilesAsync(console->fs, compareFilename, fileFound, OBJCOPY(loadPublicCartData)); 794 + tic_fs_enum(console->fs, compareFilename, fileFound, OBJCOPY(loadPublicCartData)); 795 795 796 796 return; 797 797 } ··· 800 800 console->showGameMenu = false; 801 801 s32 size = 0; 802 802 void* data = strcmp(name, CONFIG_TIC_PATH) == 0 803 - ? fsLoadRootFile(console->fs, name, &size) 804 - : fsLoadFile(console->fs, name, &size); 803 + ? tic_fs_loadroot(console->fs, name, &size) 804 + : tic_fs_load(console->fs, name, &size); 805 805 806 806 if(data) 807 807 { ··· 812 812 { 813 813 const char* name = getName(param, PROJECT_LUA_EXT); 814 814 815 - if(!fsExistsFile(console->fs, name)) 815 + if(!tic_fs_exists(console->fs, name)) 816 816 name = getName(param, PROJECT_MOON_EXT); 817 817 818 - if(!fsExistsFile(console->fs, name)) 818 + if(!tic_fs_exists(console->fs, name)) 819 819 name = getName(param, PROJECT_JS_EXT); 820 820 821 - if(!fsExistsFile(console->fs, name)) 821 + if(!tic_fs_exists(console->fs, name)) 822 822 name = getName(param, PROJECT_WREN_EXT); 823 823 824 - if(!fsExistsFile(console->fs, name)) 824 + if(!tic_fs_exists(console->fs, name)) 825 825 name = getName(param, PROJECT_FENNEL_EXT); 826 826 827 - if(!fsExistsFile(console->fs, name)) 827 + if(!tic_fs_exists(console->fs, name)) 828 828 name = getName(param, PROJECT_SQUIRREL_EXT); 829 829 830 - void* data = fsLoadFile(console->fs, name, &size); 830 + void* data = tic_fs_load(console->fs, name, &size); 831 831 832 832 if(data && tic_project_load(name, data, size, &console->tic->cart)) 833 833 onCartLoaded(console, name); ··· 1093 1093 1094 1094 if (dir) 1095 1095 { 1096 - fsChangeDir(console->fs, changeDirData->name); 1096 + tic_fs_changedir(console->fs, changeDirData->name); 1097 1097 } 1098 1098 else printBack(console, "\ndir doesn't exist"); 1099 1099 ··· 1109 1109 { 1110 1110 if(strcmp(param, "/") == 0) 1111 1111 { 1112 - fsHomeDir(console->fs); 1112 + tic_fs_homedir(console->fs); 1113 1113 } 1114 1114 else if(strcmp(param, "..") == 0) 1115 1115 { 1116 - fsDirBack(console->fs); 1116 + tic_fs_dirback(console->fs); 1117 1117 } 1118 1118 else 1119 1119 { 1120 1120 ChangeDirData data = { console, strdup(param) }; 1121 - fsIsDirAsync(console->fs, param, onConsoleChangeDirectoryDone, OBJCOPY(data)); 1121 + tic_fs_isdir_async(console->fs, param, onConsoleChangeDirectoryDone, OBJCOPY(data)); 1122 1122 return; 1123 1123 } 1124 1124 } ··· 1130 1130 static void onConsoleMakeDirectory(Console* console, const char* param) 1131 1131 { 1132 1132 if(param && strlen(param)) 1133 - fsMakeDir(console->fs, param); 1133 + tic_fs_makedir(console->fs, param); 1134 1134 else printBack(console, "\ninvalid dir name"); 1135 1135 1136 1136 commandDone(console); ··· 1141 1141 printLine(console); 1142 1142 1143 1143 PrintFileNameData data = {0, console}; 1144 - fsEnumFilesAsync(console->fs, printFilename, onDirDone, OBJCOPY(data)); 1144 + tic_fs_enum(console->fs, printFilename, onDirDone, OBJCOPY(data)); 1145 1145 } 1146 1146 1147 1147 static void onConsoleFolderCommand(Console* console, const char* param) 1148 1148 { 1149 1149 1150 1150 printBack(console, "\nStorage path:\n"); 1151 - printFront(console, fsGetRootFilePath(console->fs, "")); 1151 + printFront(console, tic_fs_pathroot(console->fs, "")); 1152 1152 1153 - fsOpenWorkingFolder(console->fs); 1153 + tic_fs_openfolder(console->fs); 1154 1154 1155 1155 commandDone(console); 1156 1156 } ··· 1166 1166 commandDoneLine(console, false); 1167 1167 } 1168 1168 1169 - static void installDemoCart(FileSystem* fs, const char* name, const void* cart, s32 size) 1169 + static void installDemoCart(tic_fs* fs, const char* name, const void* cart, s32 size) 1170 1170 { 1171 1171 u8* data = calloc(1, sizeof(tic_cartridge)); 1172 1172 ··· 1175 1175 s32 dataSize = tic_tool_unzip(data, sizeof(tic_cartridge), cart, size); 1176 1176 1177 1177 if(dataSize) 1178 - fsSaveFile(fs, name, data, dataSize, true); 1178 + tic_fs_save(fs, name, data, dataSize, true); 1179 1179 1180 1180 free(data); 1181 1181 } ··· 1233 1233 #include "../build/assets/bpp.tic.dat" 1234 1234 }; 1235 1235 1236 - FileSystem* fs = console->fs; 1236 + tic_fs* fs = console->fs; 1237 1237 1238 1238 static const struct {const char* name; const u8* data; s32 size;} Demos[] = 1239 1239 { ··· 1506 1506 if(param && filename) 1507 1507 { 1508 1508 s32 size = 0; 1509 - const void* data = fsLoadFile(console->fs, filename, &size); 1509 + const void* data = tic_fs_load(console->fs, filename, &size); 1510 1510 1511 1511 if(data) 1512 1512 { ··· 1556 1556 { 1557 1557 void* data = malloc(cover->size); 1558 1558 memcpy(data, cover->data, cover->size); 1559 - if(fsSaveFile(console->fs, filename, data, cover->size, true)) 1559 + if(tic_fs_save(console->fs, filename, data, cover->size, true)) 1560 1560 { 1561 1561 printLine(console); 1562 1562 printBack(console, filename); ··· 1631 1631 1632 1632 s32 size = 0; 1633 1633 if((size = writeGifData(console->tic, buffer, data, Width, Height)) 1634 - && fsSaveFile(console->fs, filename, buffer, size, true)) 1634 + && tic_fs_save(console->fs, filename, buffer, size, true)) 1635 1635 { 1636 1636 printLine(console); 1637 1637 printBack(console, filename); ··· 1657 1657 { 1658 1658 memcpy(buffer, getBankMap()->data, Size); 1659 1659 1660 - if(fsSaveFile(console->fs, filename, buffer, Size, true)) 1660 + if(tic_fs_save(console->fs, filename, buffer, Size, true)) 1661 1661 { 1662 1662 printLine(console); 1663 1663 printBack(console, filename); ··· 1756 1756 char filename[TICNAME_MAX]; 1757 1757 } GameExportData; 1758 1758 1759 - static void onExportGet(const HttpGetData* data) 1759 + static void onExportGet(const net_get_data* data) 1760 1760 { 1761 1761 GameExportData* exportData = (GameExportData*)data->calldata; 1762 1762 Console* console = exportData->console; 1763 1763 1764 1764 switch(data->type) 1765 1765 { 1766 - case HttpGetProgress: 1766 + case net_get_progress: 1767 1767 { 1768 1768 console->cursor.x = 0; 1769 1769 printf("\r"); ··· 1775 1775 printBack(console, buf); 1776 1776 } 1777 1777 break; 1778 - case HttpGetError: 1778 + case net_get_error: 1779 1779 free(exportData); 1780 1780 printError(console, "file downloading error :("); 1781 1781 commandDone(console); ··· 1785 1785 } 1786 1786 } 1787 1787 1788 - static void onNativeExportGet(const HttpGetData* data) 1788 + static void onNativeExportGet(const net_get_data* data) 1789 1789 { 1790 1790 switch(data->type) 1791 1791 { 1792 - case HttpGetDone: 1792 + case net_get_done: 1793 1793 { 1794 1794 GameExportData* exportData = (GameExportData*)data->calldata; 1795 1795 Console* console = exportData->console; ··· 1804 1804 1805 1805 printLine(console); 1806 1806 1807 - const char* path = fsGetFilePath(console->fs, filename); 1807 + const char* path = tic_fs_path(console->fs, filename); 1808 1808 void* buf = NULL; 1809 1809 if((buf = embedCart(console, data->done.data, &size)) 1810 - && fsWriteFile(path, buf, size)) 1810 + && fs_write(path, buf, size)) 1811 1811 { 1812 1812 chmod(path, 0755); 1813 1813 printFront(console, filename); ··· 1831 1831 } 1832 1832 } 1833 1833 1834 - static void exportGame(Console* console, const char* name, const char* system, HttpGetCallback callback) 1834 + static void exportGame(Console* console, const char* name, const char* system, net_get_callback callback) 1835 1835 { 1836 1836 tic_mem* tic = console->tic; 1837 1837 printLine(console); ··· 1841 1841 1842 1842 char url[TICNAME_MAX] = "/export/" DEF2STR(TIC_VERSION_MAJOR) "." DEF2STR(TIC_VERSION_MINOR) "/"; 1843 1843 strcat(url, system); 1844 - netGet(console->net, url, callback, data); 1844 + tic_net_get(console->net, url, callback, data); 1845 1845 } 1846 1846 1847 1847 static inline void exportNativeGame(Console* console, const char* name, const char* system) ··· 1849 1849 exportGame(console, name, system, onNativeExportGet); 1850 1850 } 1851 1851 1852 - static void onHtmlExportGet(const HttpGetData* data) 1852 + static void onHtmlExportGet(const net_get_data* data) 1853 1853 { 1854 1854 switch(data->type) 1855 1855 { 1856 - case HttpGetDone: 1856 + case net_get_done: 1857 1857 { 1858 1858 GameExportData* exportData = (GameExportData*)data->calldata; 1859 1859 Console* console = exportData->console; ··· 1864 1864 strcpy(filename, exportData->filename); 1865 1865 free(exportData); 1866 1866 1867 - const char* zipPath = fsGetFilePath(console->fs, filename); 1867 + const char* zipPath = tic_fs_path(console->fs, filename); 1868 1868 1869 - if(!fsWriteFile(zipPath, data->done.data, data->done.size)) 1869 + if(!fs_write(zipPath, data->done.data, data->done.size)) 1870 1870 { 1871 1871 printError(console, "\nerror: "); 1872 1872 printError(console, filename); ··· 2018 2018 size = tic_cart_save(&tic->cart, buffer); 2019 2019 } 2020 2020 2021 - if(size && fsSaveFile(console->fs, name, buffer, size, true)) 2021 + if(size && tic_fs_save(console->fs, name, buffer, size, true)) 2022 2022 { 2023 - setCartName(console, name, fsGetFilePath(console->fs, name)); 2023 + setCartName(console, name, tic_fs_path(console->fs, name)); 2024 2024 success = true; 2025 2025 studioRomSaved(); 2026 2026 } ··· 2064 2064 static void onConsoleSaveCommand(Console* console, const char* param) 2065 2065 { 2066 2066 if(param && strlen(param) && 2067 - (fsExistsFile(console->fs, param) || 2068 - fsExistsFile(console->fs, getCartName(param)))) 2067 + (tic_fs_exists(console->fs, param) || 2068 + tic_fs_exists(console->fs, getCartName(param)))) 2069 2069 { 2070 2070 static const char* Rows[] = 2071 2071 { ··· 2125 2125 { 2126 2126 if(param && strlen(param)) 2127 2127 { 2128 - if (fsIsInPublicDir(console->fs)) 2128 + if (tic_fs_ispubdir(console->fs)) 2129 2129 { 2130 2130 printError(console, "\naccess denied"); 2131 2131 } 2132 2132 else 2133 2133 { 2134 - if(fsIsDir(console->fs, param)) 2134 + if(tic_fs_isdir(console->fs, param)) 2135 2135 { 2136 - printBack(console, fsDeleteDir(console->fs, param) 2136 + printBack(console, tic_fs_deldir(console->fs, param) 2137 2137 ? "\ndir not deleted" 2138 2138 : "\ndir successfully deleted"); 2139 2139 } 2140 2140 else 2141 2141 { 2142 - printBack(console, fsDeleteFile(console->fs, param) 2142 + printBack(console, tic_fs_delfile(console->fs, param) 2143 2143 ? "\nfile not deleted" 2144 2144 : "\nfile successfully deleted"); 2145 2145 } ··· 2300 2300 { 2301 2301 if(name) 2302 2302 { 2303 - const char* path = fsGetFilePath(console->fs, name); 2303 + const char* path = tic_fs_path(console->fs, name); 2304 2304 2305 - if(!fsExists(path)) 2305 + if(!fs_exists(path)) 2306 2306 { 2307 - if(fsWriteFile(path, buffer, size)) 2307 + if(fs_write(path, buffer, size)) 2308 2308 { 2309 2309 printLine(console); 2310 2310 printFront(console, name); ··· 2356 2356 { 2357 2357 if(name) 2358 2358 { 2359 - const char* path = fsGetFilePath(console->fs, name); 2359 + const char* path = tic_fs_path(console->fs, name); 2360 2360 2361 - if(fsExists(path)) 2361 + if(fs_exists(path)) 2362 2362 { 2363 2363 s32 size = 0; 2364 - void* buffer = fsReadFile(path, &size); 2364 + void* buffer = fs_read(path, &size); 2365 2365 2366 2366 EM_ASM_ 2367 2367 ({ ··· 2464 2464 if(param && strlen(++param)) 2465 2465 { 2466 2466 PredictFilenameData data = { console, param }; 2467 - fsEnumFilesAsync(console->fs, predictFilename, predictFilenameDone, OBJCOPY(data)); 2467 + tic_fs_enum(console->fs, predictFilename, predictFilenameDone, OBJCOPY(data)); 2468 2468 } 2469 2469 else 2470 2470 { ··· 2743 2743 return NULL; 2744 2744 } 2745 2745 2746 - static void onHttpVesrsionGet(const HttpGetData* data) 2746 + static void onHttpVesrsionGet(const net_get_data* data) 2747 2747 { 2748 2748 Console* console = (Console*)data->calldata; 2749 2749 2750 2750 switch(data->type) 2751 2751 { 2752 - case HttpGetDone: 2752 + case net_get_done: 2753 2753 { 2754 2754 lua_State* lua = netLuaInit(data->done.data, data->done.size); 2755 2755 ··· 2942 2942 printBack(console, " for help\n"); 2943 2943 2944 2944 if(getConfig()->checkNewVersion) 2945 - netGet(console->net, "/api?fn=version", onHttpVesrsionGet, console); 2945 + tic_net_get(console->net, "/api?fn=version", onHttpVesrsionGet, console); 2946 2946 2947 2947 commandDone(console); 2948 2948 } ··· 2991 2991 console->tickCounter++; 2992 2992 } 2993 2993 2994 + static inline bool isslash(char c) 2995 + { 2996 + return c == '/' && c == '\\'; 2997 + } 2998 + 2994 2999 static bool cmdLoadCart(Console* console, const char* path) 2995 3000 { 2996 3001 bool done = false; 2997 3002 2998 3003 s32 size = 0; 2999 - void* data = fsReadFile(path, &size); 3004 + void* data = fs_read(path, &size); 3000 3005 3001 3006 if(data) 3002 3007 { 3003 - char cartName[TICNAME_MAX]; 3004 - fsFilename(path, cartName); 3008 + const char* cartName = NULL; 3009 + 3010 + { 3011 + const char* ptr = path + strlen(path); 3012 + while(ptr > path && !isslash(*ptr))--ptr; 3013 + cartName = ptr; 3014 + } 3015 + 3005 3016 setCartName(console, cartName, path); 3006 3017 3007 3018 if(hasProjectExt(cartName)) ··· 3022 3033 return done; 3023 3034 } 3024 3035 3025 - void initConsole(Console* console, tic_mem* tic, FileSystem* fs, Net* net, Config* config, StartArgs args) 3036 + void initConsole(Console* console, tic_mem* tic, tic_fs* fs, tic_net* net, Config* config, StartArgs args) 3026 3037 { 3027 3038 if(!console->buffer) console->buffer = malloc(CONSOLE_BUFFER_SIZE); 3028 3039 if(!console->colorBuffer) console->colorBuffer = malloc(CONSOLE_BUFFER_SIZE); ··· 3097 3108 #endif 3098 3109 3099 3110 s32 appSize = 0; 3100 - u8* app = fsReadFile(appPath, &appSize); 3111 + u8* app = fs_read(appPath, &appSize); 3101 3112 3102 3113 if(app) 3103 3114 {
+5 -5
src/studio/screens/console.h
··· 24 24 25 25 #include "studio/studio.h" 26 26 27 - typedef void(*DoneCallback)(void* data); 27 + typedef void(*fs_done_callback)(void* data); 28 28 29 29 typedef enum 30 30 { ··· 77 77 78 78 tic_mem* tic; 79 79 80 - struct FileSystem* fs; 81 - struct Net* net; 80 + struct tic_fs* fs; 81 + struct tic_net* net; 82 82 83 83 struct 84 84 { ··· 96 96 StartArgs args; 97 97 98 98 void(*load)(Console*, const char* path); 99 - void(*loadByHash)(Console*, const char* name, const char* hash, DoneCallback callback, void* data); 99 + void(*loadByHash)(Console*, const char* name, const char* hash, fs_done_callback callback, void* data); 100 100 void(*updateProject)(Console*); 101 101 void(*error)(Console*, const char*); 102 102 void(*trace)(Console*, const char*, u8 color); ··· 105 105 CartSaveResult(*save)(Console*); 106 106 }; 107 107 108 - void initConsole(Console*, tic_mem*, struct FileSystem* fs, struct Net* net, struct Config* config, StartArgs args); 108 + void initConsole(Console*, tic_mem*, struct tic_fs* fs, struct tic_net* net, struct Config* config, StartArgs args); 109 109 void freeConsole(Console* console);
+2 -2
src/studio/screens/menu.c
··· 455 455 456 456 static void saveMapping(Menu* menu) 457 457 { 458 - fsSaveRootFile(menu->fs, KEYMAP_DAT_PATH, getKeymap(), KEYMAP_SIZE, true); 458 + tic_fs_saveroot(menu->fs, KEYMAP_DAT_PATH, getKeymap(), KEYMAP_SIZE, true); 459 459 } 460 460 461 461 static void processKeyboard(Menu* menu) ··· 540 540 } 541 541 } 542 542 543 - void initMenu(Menu* menu, tic_mem* tic, FileSystem* fs) 543 + void initMenu(Menu* menu, tic_mem* tic, tic_fs* fs) 544 544 { 545 545 *menu = (Menu) 546 546 {
+2 -2
src/studio/screens/menu.h
··· 29 29 struct Menu 30 30 { 31 31 tic_mem* tic; 32 - struct FileSystem* fs; 32 + struct tic_fs* fs; 33 33 34 34 bool init; 35 35 s32 ticks; ··· 64 64 void (*overline)(tic_mem* tic, void* data); 65 65 }; 66 66 67 - void initMenu(Menu* menu, tic_mem* tic, struct FileSystem* fs); 67 + void initMenu(Menu* menu, tic_mem* tic, struct tic_fs* fs); 68 68 void freeMenu(Menu* menu);
+2 -2
src/studio/screens/run.c
··· 109 109 110 110 if(memcmp(run->pmem.data, tic->ram.persistent.data, Size)) 111 111 { 112 - fsSaveRootFile(run->console->fs, run->saveid, &tic->ram.persistent, Size, true); 112 + tic_fs_saveroot(run->console->fs, run->saveid, &tic->ram.persistent, Size, true); 113 113 memcpy(run->pmem.data, tic->ram.persistent.data, Size); 114 114 } 115 115 ··· 164 164 initPMemName(run); 165 165 166 166 s32 size = 0; 167 - void* data = fsLoadRootFile(run->console->fs, run->saveid, &size); 167 + void* data = tic_fs_loadroot(run->console->fs, run->saveid, &size); 168 168 169 169 if(data) 170 170 {
+22 -22
src/studio/screens/surf.c
··· 166 166 MenuItem* items; 167 167 s32 count; 168 168 Surf* surf; 169 - DoneCallback done; 169 + fs_done_callback done; 170 170 void* data; 171 171 } AddMenuItemData; 172 172 ··· 231 231 { 232 232 char label[TICNAME_MAX + 1]; 233 233 char dir[TICNAME_MAX]; 234 - fsGetDir(surf->fs, dir); 234 + tic_fs_dir(surf->fs, dir); 235 235 236 236 sprintf(label, "/%s", dir); 237 237 s32 xl = x + MAIN_OFFSET; ··· 464 464 char dir[TICNAME_MAX]; 465 465 } CoverLoadingData; 466 466 467 - static void coverLoaded(const HttpGetData* netData) 467 + static void coverLoaded(const net_get_data* netData) 468 468 { 469 469 CoverLoadingData* coverLoadingData = netData->calldata; 470 470 Surf* surf = coverLoadingData->surf; 471 471 472 - if (netData->type == HttpGetDone) 472 + if (netData->type == net_get_done) 473 473 { 474 - fsSaveRootFile(surf->fs, coverLoadingData->cachePath, netData->done.data, netData->done.size, false); 474 + tic_fs_saveroot(surf->fs, coverLoadingData->cachePath, netData->done.data, netData->done.size, false); 475 475 476 476 char dir[TICNAME_MAX]; 477 - fsGetDir(surf->fs, dir); 477 + tic_fs_dir(surf->fs, dir); 478 478 479 479 if(strcmp(dir, coverLoadingData->dir) == 0) 480 480 updateMenuItemCover(surf, coverLoadingData->pos, netData->done.data, netData->done.size); ··· 482 482 483 483 switch (netData->type) 484 484 { 485 - case HttpGetDone: 486 - case HttpGetError: 485 + case net_get_done: 486 + case net_get_error: 487 487 free(coverLoadingData); 488 488 break; 489 489 } ··· 492 492 static void requestCover(Surf* surf, MenuItem* item) 493 493 { 494 494 CoverLoadingData coverLoadingData = {surf, surf->menu.pos}; 495 - fsGetDir(surf->fs, coverLoadingData.dir); 495 + tic_fs_dir(surf->fs, coverLoadingData.dir); 496 496 497 497 const char* hash = item->hash; 498 498 sprintf(coverLoadingData.cachePath, TIC_CACHE "%s.gif", hash); 499 499 500 500 { 501 501 s32 size = 0; 502 - void* data = fsLoadRootFile(surf->fs, coverLoadingData.cachePath, &size); 502 + void* data = tic_fs_loadroot(surf->fs, coverLoadingData.cachePath, &size); 503 503 504 504 if (data) 505 505 { ··· 511 511 char path[TICNAME_MAX]; 512 512 sprintf(path, "/cart/%s/cover.gif", hash); 513 513 514 - netGet(surf->net, path, coverLoaded, OBJCOPY(coverLoadingData)); 514 + tic_net_get(surf->net, path, coverLoaded, OBJCOPY(coverLoadingData)); 515 515 } 516 516 517 517 static void loadCover(Surf* surf) ··· 525 525 526 526 item->coverLoading = true; 527 527 528 - if(!fsIsInPublicDir(surf->fs)) 528 + if(!tic_fs_ispubdir(surf->fs)) 529 529 { 530 530 531 531 s32 size = 0; 532 - void* data = fsLoadFile(surf->fs, item->name, &size); 532 + void* data = tic_fs_load(surf->fs, item->name, &size); 533 533 534 534 if(data) 535 535 { ··· 558 558 } 559 559 } 560 560 561 - static void initMenuAsync(Surf* surf, DoneCallback callback, void* calldata) 561 + static void initMenuAsync(Surf* surf, fs_done_callback callback, void* calldata) 562 562 { 563 563 resetMenu(surf); 564 564 565 565 surf->loading = true; 566 566 567 567 char dir[TICNAME_MAX]; 568 - fsGetDir(surf->fs, dir); 568 + tic_fs_dir(surf->fs, dir); 569 569 570 570 AddMenuItemData data = { NULL, 0, surf, callback, calldata}; 571 571 572 572 if(strcmp(dir, "") != 0) 573 573 addMenuItem("..", NULL, 0, &data, true); 574 574 575 - fsEnumFilesAsync(surf->fs, addMenuItem, addMenuItemsDone, OBJCOPY(data)); 575 + tic_fs_enum(surf->fs, addMenuItem, addMenuItemsDone, OBJCOPY(data)); 576 576 } 577 577 578 578 typedef struct ··· 592 592 Surf* surf = goBackDirDoneData->surf; 593 593 594 594 char current[TICNAME_MAX]; 595 - fsGetDir(surf->fs, current); 595 + tic_fs_dir(surf->fs, current); 596 596 597 597 for(s32 i = 0; i < surf->menu.count; i++) 598 598 { ··· 621 621 static void onGoBackDir(Surf* surf) 622 622 { 623 623 char last[TICNAME_MAX]; 624 - fsGetDir(surf->fs, last); 624 + tic_fs_dir(surf->fs, last); 625 625 626 - fsDirBack(surf->fs); 626 + tic_fs_dirback(surf->fs); 627 627 628 628 GoBackDirDoneData goBackDirDoneData = {surf, strdup(last)}; 629 629 initMenuAsync(surf, onGoBackDirDone, OBJCOPY(goBackDirDoneData)); ··· 633 633 { 634 634 MenuItem* item = &surf->menu.items[surf->menu.pos]; 635 635 636 - fsChangeDir(surf->fs, item->name); 636 + tic_fs_changedir(surf->fs, item->name); 637 637 initMenu(surf); 638 638 } 639 639 640 640 static void goBackDir(Surf* surf) 641 641 { 642 642 char dir[TICNAME_MAX]; 643 - fsGetDir(surf->fs, dir); 643 + tic_fs_dir(surf->fs, dir); 644 644 645 645 if(strcmp(dir, "") != 0) 646 646 { ··· 925 925 .scanline = scanline, 926 926 }; 927 927 928 - fsMakeDir(surf->fs, TIC_CACHE); 928 + tic_fs_makedir(surf->fs, TIC_CACHE); 929 929 } 930 930 931 931 void freeSurf(Surf* surf)
+2 -2
src/studio/screens/surf.h
··· 29 29 struct Surf 30 30 { 31 31 tic_mem* tic; 32 - struct FileSystem* fs; 33 - struct Net* net; 32 + struct tic_fs* fs; 33 + struct tic_net* net; 34 34 struct Console* console; 35 35 struct Movie* state; 36 36
+19 -19
src/studio/studio.c
··· 185 185 Surf* surf; 186 186 }; 187 187 188 - FileSystem* fs; 189 - Net* net; 188 + tic_fs* fs; 189 + tic_net* net; 190 190 191 191 s32 samplerate; 192 192 tic_font systemFont; ··· 288 288 { 289 289 tic_mem* tic = impl.studio.tic; 290 290 291 - const char* path = fsGetFilePath(impl.fs, filename); 291 + const char* path = tic_fs_path(impl.fs, filename); 292 292 293 293 if(wave_open( impl.samplerate, path )) 294 294 { ··· 333 333 { 334 334 tic_mem* tic = impl.studio.tic; 335 335 336 - const char* path = fsGetFilePath(impl.fs, filename); 336 + const char* path = tic_fs_path(impl.fs, filename); 337 337 338 338 if(wave_open( impl.samplerate, path )) 339 339 { ··· 1307 1307 1308 1308 static void updateMDate() 1309 1309 { 1310 - impl.cart.mdate = fsMDate(impl.console->rom.path); 1310 + impl.cart.mdate = fs_date(impl.console->rom.path); 1311 1311 } 1312 1312 1313 1313 static void updateTitle() ··· 1461 1461 { 1462 1462 snprintf(filename, sizeof filename, name, ++i); 1463 1463 } 1464 - while(fsExistsFile(impl.fs, filename)); 1464 + while(tic_fs_exists(impl.fs, filename)); 1465 1465 1466 1466 // Now that it has found an available filename, save it. 1467 - if(fsSaveFile(impl.fs, filename, data, size, true)) 1467 + if(tic_fs_save(impl.fs, filename, data, size, true)) 1468 1468 { 1469 1469 char msg[TICNAME_MAX]; 1470 1470 sprintf(msg, "%s saved :)", filename); 1471 1471 showPopupMessage(msg); 1472 1472 1473 - tic_sys_open_path(fsGetFilePath(impl.fs, filename)); 1473 + tic_sys_open_path(tic_fs_path(impl.fs, filename)); 1474 1474 } 1475 1475 else showPopupMessage("error: file not saved :("); 1476 1476 } ··· 1626 1626 { 1627 1627 Console* console = impl.console; 1628 1628 1629 - u64 date = fsMDate(console->rom.path); 1629 + u64 date = fs_date(console->rom.path); 1630 1630 1631 1631 if(impl.cart.mdate && date > impl.cart.mdate) 1632 1632 { ··· 1844 1844 1845 1845 static void initKeymap() 1846 1846 { 1847 - FileSystem* fs = impl.fs; 1847 + tic_fs* fs = impl.fs; 1848 1848 1849 1849 s32 size = 0; 1850 - u8* data = (u8*)fsLoadFile(fs, KEYMAP_DAT_PATH, &size); 1850 + u8* data = (u8*)tic_fs_load(fs, KEYMAP_DAT_PATH, &size); 1851 1851 1852 1852 if(data) 1853 1853 { ··· 1891 1891 { 1892 1892 tic_mem* tic = impl.studio.tic; 1893 1893 1894 - netTickStart(impl.net); 1894 + tic_net_start(impl.net); 1895 1895 processShortcuts(); 1896 1896 processMouseStates(); 1897 1897 processGamepadMapping(); ··· 1969 1969 1970 1970 drawPopup(); 1971 1971 1972 - netTickEnd(impl.net); 1972 + tic_net_end(impl.net); 1973 1973 } 1974 1974 1975 1975 static void studioClose() ··· 1997 1997 if(impl.tic80local) 1998 1998 tic80_delete((tic80*)impl.tic80local); 1999 1999 2000 - netClose(impl.net); 2000 + tic_net_close(impl.net); 2001 2001 free(impl.fs); 2002 2002 } 2003 2003 ··· 2044 2044 StartArgs args = parseArgs(argc, argv); 2045 2045 2046 2046 impl.samplerate = samplerate; 2047 - impl.net = netCreate(TIC_WEBSITE); 2047 + impl.net = tic_net_create(TIC_WEBSITE); 2048 2048 2049 2049 { 2050 2050 const char *path = args.fs ? args.fs : folder; 2051 2051 2052 - if(fsExists(path)) 2053 - impl.fs = createFileSystem(path, impl.net); 2052 + if(fs_exists(path)) 2053 + impl.fs = tic_fs_create(path, impl.net); 2054 2054 else 2055 2055 { 2056 2056 fprintf(stderr, "error: folder `%s` doesn't exist\n", path); ··· 2081 2081 impl.surf = calloc(1, sizeof(Surf)); 2082 2082 } 2083 2083 2084 - fsMakeDir(impl.fs, TIC_LOCAL); 2085 - fsMakeDir(impl.fs, TIC_LOCAL_VERSION); 2084 + tic_fs_makedir(impl.fs, TIC_LOCAL); 2085 + tic_fs_makedir(impl.fs, TIC_LOCAL_VERSION); 2086 2086 2087 2087 initConfig(impl.config, impl.studio.tic, impl.fs); 2088 2088 initKeymap();