14 if (!
fn || !
mode)
return 0;
20#ifdef EEL_STRING_DEBUGOUT
21 if (ret < 0) EEL_STRING_DEBUGOUT(
"fclose(): file handle %f not valid",*fpp);
29 if (fp)
return (EEL_F)fgetc(fp);
30#ifdef EEL_STRING_DEBUGOUT
31 EEL_STRING_DEBUGOUT(
"fgetc(): file handle %f not valid",*fpp);
40 if (fp)
return (EEL_F)ftell(fp);
41#ifdef EEL_STRING_DEBUGOUT
42 EEL_STRING_DEBUGOUT(
"ftell(): file handle %f not valid",*fpp);
50 if (fp) { fflush(fp);
return 0.0; }
51#ifdef EEL_STRING_DEBUGOUT
52 EEL_STRING_DEBUGOUT(
"fflush(): file handle %f not valid",*fpp);
61 if (fp)
return feof(fp) ? 1.0 : 0.0;
62#ifdef EEL_STRING_DEBUGOUT
63 EEL_STRING_DEBUGOUT(
"feof(): file handle %f not valid",*fpp);
71 if (fp)
return fseek(fp, (
int) *offset, *wh<0 ? SEEK_SET : *wh > 0 ?
SEEK_END :
SEEK_CUR);
72#ifdef EEL_STRING_DEBUGOUT
73 EEL_STRING_DEBUGOUT(
"fseek(): file handle %f not valid",*fpp);
86#ifdef EEL_STRING_DEBUGOUT
87 EEL_STRING_DEBUGOUT(
"fgets(): file handle %f not valid",*fpp);
94 fgets(buf,
sizeof(buf),fp);
98 return (EEL_F)wr->GetLength();
102#ifdef EEL_STRING_DEBUGOUT
103 EEL_STRING_DEBUGOUT(
"fgets: bad destination specifier passed %f, throwing away %d bytes",*strOut, (
int)strlen(buf));
105 return (
int)strlen(buf);
110 int use_len = (
int) *flen;
111 if (use_len < 1)
return 0.0;
118#ifdef EEL_STRING_DEBUGOUT
119 EEL_STRING_DEBUGOUT(
"fread: bad destination specifier passed %f, not reading %d bytes",*strOut, use_len);
127#ifdef EEL_STRING_DEBUGOUT
128 EEL_STRING_DEBUGOUT(
"fread(): file handle %f not valid",*fpp);
135 if (wr->GetLength() != use_len)
137#ifdef EEL_STRING_DEBUGOUT
138 EEL_STRING_DEBUGOUT(
"fread: error allocating storage for read of %d bytes", use_len);
142 use_len = (
int)fread((
char *)wr->Get(),1,use_len,fp);
143 wr->SetLen(use_len > 0 ? use_len : 0,
true);
144 return (EEL_F) use_len;
150 int use_len = (
int) *flen;
156#ifdef EEL_STRING_DEBUGOUT
157 EEL_STRING_DEBUGOUT(
"fwrite: bad source specifier passed %f, not writing %d bytes",*strOut, use_len);
163 const int ssl = (
int)strlen(str);
164 if (use_len < 1 || use_len > ssl) use_len = ssl;
168 if (use_len < 1 || use_len > wr->GetLength()) use_len = wr->GetLength();
171 if (use_len < 1)
return 0.0;
176#ifdef EEL_STRING_DEBUGOUT
177 EEL_STRING_DEBUGOUT(
"fwrite(): file handle %f not valid",*fpp);
182 return (EEL_F) fwrite(str,1,use_len,fp);
193#ifdef EEL_STRING_DEBUGOUT
194 EEL_STRING_DEBUGOUT(
"fprintf(): file handle %f not valid",
parm[0][0]);
208 return (EEL_F) fwrite(buf,1,len,fp);
212#ifdef EEL_STRING_DEBUGOUT
213 EEL_STRING_DEBUGOUT(
"fprintf: bad format string %s",
fmt);
219#ifdef EEL_STRING_DEBUGOUT
220 EEL_STRING_DEBUGOUT(
"fprintf: bad format specifier passed %f",*(
parm[1]));
245#ifdef EEL_WANT_DOCUMENTATION
246static const char *eel_file_function_reference =
247"fopen\t\"fn\",\"mode\"\tOpens a file \"fn\" with mode \"mode\". For read, use \"r\" or \"rb\", write \"w\" or \"wb\". Returns a positive integer on success.\0"
248"fclose\tfp\tCloses a file previously opened with fopen().\0"
249"fread\tfp,#str,length\tReads from file fp into #str, up to length bytes. Returns actual length read, or negative if error.\0"
250"fgets\tfp,#str\tReads a line from file fp into #str. Returns length of #str read.\0"
251"fgetc\tfp\tReads a character from file fp, returns -1 if EOF.\0"
252"fwrite\tfp,#str,len\tWrites up to len characters of #str to file fp. If len is less than 1, the full contents of #str will be written. Returns the number of bytes written to file.\0"
253"fprintf\tfp,\"format\"[,...]\tFormats a string and writes it to file fp. For more information on format specifiers, see sprintf(). Returns bytes written to file.\0"
254"fseek\tfp,offset,whence\tSeeks file fp, offset bytes from whence reference. Whence negative specifies start of file, positive whence specifies end of file, and zero whence specifies current file position.\0"
255"ftell\tfp\tRetunrs the current file position.\0"
256"feof\tfp\tReturns nonzero if the file fp is at the end of file.\0"
257"fflush\tfp\tIf file fp is open for writing, flushes out any buffered data to disk.\0"
static EEL_F NSEEL_CGEN_CALL _eel_fread(void *opaque, EEL_F *fpp, EEL_F *strOut, EEL_F *flen)
Definition eel_files.h:108
void EEL_file_register()
Definition eel_files.h:227
static EEL_F NSEEL_CGEN_CALL _eel_fclose(void *opaque, EEL_F *fpp)
Definition eel_files.h:17
static EEL_F NSEEL_CGEN_CALL _eel_fgetc(void *opaque, EEL_F *fpp)
Definition eel_files.h:25
static EEL_F NSEEL_CGEN_CALL _eel_ftell(void *opaque, EEL_F *fpp)
Definition eel_files.h:36
static EEL_F NSEEL_CGEN_CALL _eel_fwrite(void *opaque, EEL_F *fpp, EEL_F *strOut, EEL_F *flen)
Definition eel_files.h:147
static EEL_F NSEEL_CGEN_CALL _eel_fgets(void *opaque, EEL_F *fpp, EEL_F *strOut)
Definition eel_files.h:77
static EEL_F NSEEL_CGEN_CALL _eel_feof(void *opaque, EEL_F *fpp)
Definition eel_files.h:57
static EEL_F NSEEL_CGEN_CALL _eel_fflush(void *opaque, EEL_F *fpp)
Definition eel_files.h:46
static EEL_F NSEEL_CGEN_CALL _eel_fprintf(void *opaque, INT_PTR nparam, EEL_F **parm)
Definition eel_files.h:185
static EEL_F NSEEL_CGEN_CALL _eel_fopen(void *opaque, EEL_F *fn_index, EEL_F *mode_index)
Definition eel_files.h:9
static EEL_F NSEEL_CGEN_CALL _eel_fseek(void *opaque, EEL_F *fpp, EEL_F *offset, EEL_F *wh)
Definition eel_files.h:67
#define NSEEL_addfunc_varparm(name, min_np, pproc, fptr)
Definition eel_import.h:63
#define NSEEL_addfunc_retval(name, np, pproc, fptr)
Definition eel_import.h:51
void *(* NSEEL_PProc_THIS)(void *data, int data_size, struct _compileContext *ctx)
Definition eel_import.h:40
#define EEL_STRING_GET_FOR_WRITE(x, wr)
Definition eel_strings.h:100
#define EEL_STRING_GET_FOR_INDEX(x, wr)
Definition eel_strings.h:96
#define EEL_STRING_STORAGECLASS
Definition eel_strings.h:116
#define EEL_STRING_MUTEXLOCK_SCOPE
Definition eel_strings.h:90
int eel_format_strings(void *opaque, const char *fmt, const char *fmt_end, char *buf, int buf_sz, int num_fmt_parms, EEL_F **fmt_parms)
Definition eel_strings.h:402
#define opaque
Definition eelscript.h:281
#define EEL_FILE_CLOSE(fpindex)
Definition eelscript.h:182
#define EEL_FILE_OPEN(fn, mode)
Definition eelscript.h:180
#define EEL_FILE_GETFP(fp)
Definition eelscript.h:181
#define NSEEL_CGEN_CALL
Definition ns-eel.h:44
png_structrp int mode
Definition png.h:1139
const char const char const char const char char * fn
Definition swell-functions.h:168
void DWORD DWORD LPVOID parm
Definition swell-functions.h:807
intptr_t INT_PTR
Definition swell-types.h:42
fmt[0]
Definition fileio.c:2503
typedef int(UZ_EXP MsgFn)()
#define SEEK_CUR
Definition unzpriv.h:1303
#define SEEK_END
Definition unzpriv.h:1304