Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
65 lines (49 loc) · 1.76 KB

File metadata and controls

65 lines (49 loc) · 1.76 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
This file is part of Iceball.
Iceball is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Iceball is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Iceball. If not, see <http://www.gnu.org/licenses/>.
*/
int icelua_fn_common_bin_load(lua_State *L)
{
int top = icelua_assert_stack(L, 1, 1);
const char *fname = lua_tostring(L, 1);
if(fname == NULL)
return luaL_error(L, "filename must be a string");
lua_getglobal(L, "common");
lua_getfield(L, -1, "fetch_block");
lua_remove(L, -2);
lua_pushstring(L, "bin");
lua_pushvalue(L, 1);
lua_call(L, 2, 1);
return 1;
}
int icelua_fn_common_bin_save(lua_State *L)
{
int top = icelua_assert_stack(L, 2, 2);
size_t fdlen = 0;
const char *fname = lua_tostring(L, 1);
const char *fdata = lua_tolstring(L, 2, &fdlen);
if(fname == NULL)
return luaL_error(L, "filename must be a string");
if(fdata == NULL)
return luaL_error(L, "data must be a string");
if(L != lstate_server && !bin_storage_allowed)
return luaL_error(L, "saving disabled");
if(L == lstate_server
? !path_type_server_writable(path_get_type(fname))
: !path_type_client_writable(path_get_type(fname)))
return luaL_error(L, "cannot write to there %d",path_get_type(fname));
FILE *fp = fopen(fname, "wb");
fwrite(fdata, fdlen, 1, fp);
fclose(fp);
lua_pushboolean(L, 1);
return 1;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.