this repo has no description
0
fork

Configure Feed

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

download WASM export data as solid .zip

Nesbox 8f398802 efb45861

+28 -56
+28 -56
src/console.c
··· 52 52 #define CONSOLE_BUFFER_HEIGHT (STUDIO_TEXT_BUFFER_HEIGHT) 53 53 #define CONSOLE_BUFFER_SCREENS 64 54 54 #define CONSOLE_BUFFER_SIZE (CONSOLE_BUFFER_WIDTH * CONSOLE_BUFFER_HEIGHT * CONSOLE_BUFFER_SCREENS) 55 + #define HTML_EXPORT_NAME "html.zip" 55 56 56 57 typedef enum 57 58 { ··· 1749 1750 return name; 1750 1751 } 1751 1752 1752 - static void onHttpGet(const HttpGetData* data) 1753 + static struct{const void* data; s32 size;} htmlExportZip = {NULL, 0}; 1754 + 1755 + static void onHtmlExportGet(const HttpGetData* data) 1753 1756 { 1754 1757 Console* console = (Console*)data->calldata; 1755 1758 ··· 1768 1771 break; 1769 1772 case HttpGetDone: 1770 1773 { 1771 - char path[TICNAME_MAX] = TIC_LOCAL_VERSION; 1772 - strcat(path, md5str(data->url, strlen(data->url))); 1773 - 1774 - if(fsSaveRootFile(console->fs, path, data->done.data, data->done.size, false)) 1775 - { 1776 - console->cursor.x = 0; 1777 - printBack(console, "GET "); 1778 - printFront(console, data->url); 1779 - printBack(console, " [DONE]"); 1780 - 1781 - onConsoleExportHtmlCommand(console, NULL); 1782 - } 1783 - else 1784 - { 1785 - printError(console, "file saving error :("); 1786 - commandDone(console); 1787 - } 1774 + htmlExportZip.data = data->done.data; 1775 + htmlExportZip.size = data->done.size; 1776 + onConsoleExportHtmlCommand(console, NULL); 1788 1777 } 1789 1778 break; 1790 1779 case HttpGetError: ··· 1800 1789 1801 1790 #if defined(__TIC_WINDOWS__) 1802 1791 1803 - static const char HtmlName[] = "html.zip"; 1804 - const char* name = HtmlName; 1792 + static const char HtmlName[] = HTML_EXPORT_NAME; 1793 + const char* zipPath = HtmlName; 1805 1794 1806 1795 #else 1807 1796 1808 - static const char HtmlName[] = TIC_CACHE "html.zip"; 1809 - const char* name = fsGetRootFilePath(console->fs, HtmlName); 1797 + static const char HtmlName[] = TIC_CACHE HTML_EXPORT_NAME; 1798 + const char* zipPath = fsGetRootFilePath(console->fs, HtmlName); 1810 1799 1811 1800 #endif 1812 1801 1813 - struct zip_t *zip = zip_open(name, ZIP_DEFAULT_COMPRESSION_LEVEL, 'w'); 1802 + if(htmlExportZip.data) 1803 + { 1804 + if(!fsWriteFile(zipPath, htmlExportZip.data, htmlExportZip.size)) 1805 + { 1806 + printError(console, "file saving error :("); 1807 + commandDone(console); 1808 + return; 1809 + } 1810 + } 1811 + else 1812 + { 1813 + printLine(console); 1814 + return getSystem()->httpGet("/export/" DEF2STR(TIC_VERSION_MAJOR) "." DEF2STR(TIC_VERSION_MINOR) "/" HTML_EXPORT_NAME, onHtmlExportGet, console); 1815 + } 1816 + 1817 + struct zip_t *zip = zip_open(zipPath, ZIP_DEFAULT_COMPRESSION_LEVEL, 'a'); 1814 1818 bool errorOccured = false; 1815 1819 1816 1820 if(zip) 1817 1821 { 1818 - static const char* Files[] = 1819 - { 1820 - "index.html", "tic80.js", "tic80.wasm" 1821 - }; 1822 - 1823 - for(s32 i = 0; i < COUNT_OF(Files); i++) 1824 - { 1825 - char url[TICNAME_MAX] = "/export/" DEF2STR(TIC_VERSION_MAJOR) "." DEF2STR(TIC_VERSION_MINOR) "/"; 1826 - strcat(url, Files[i]); 1827 - s32 size = 0; 1828 - 1829 - char path[TICNAME_MAX] = TIC_LOCAL_VERSION; 1830 - strcat(path, md5str(url, strlen(url))); 1831 - 1832 - void* data = fsLoadRootFile(console->fs, path, &size); 1833 - 1834 - if(data) 1835 - { 1836 - zip_entry_open(zip, Files[i]); 1837 - zip_entry_write(zip, data, size); 1838 - zip_entry_close(zip); 1839 - 1840 - free(data); 1841 - } 1842 - else 1843 - { 1844 - zip_close(zip); 1845 - printLine(console); 1846 - return getSystem()->httpGet(url, onHttpGet, console); 1847 - } 1848 - } 1849 - 1850 1822 printBack(console, "\nexporting html...\n"); 1851 1823 1852 1824 // save cart ··· 1879 1851 #if defined(__TIC_WINDOWS__) 1880 1852 // Temporary workaround for #1169, because ZIP lib doesn't work with wide filenames, 1881 1853 // we store it the working dir and remove at the end. 1882 - void* data = fsReadFile(name, &size); 1854 + void* data = fsReadFile(zipPath, &size); 1883 1855 remove(HtmlName); 1884 1856 #else 1885 1857 void* data = fsLoadRootFile(console->fs, HtmlName, &size);