MCPcopy Create free account
hub / github.com/TASEmulators/fceux / FCEUNET_SendFile

Function FCEUNET_SendFile

src/netplay.cpp:112–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112int FCEUNET_SendFile(uint8 cmd, char *fn)
113{
114 uint32 len;
115 uLongf clen;
116 char *buf, *cbuf;
117 FILE *fp;
118 struct stat sb;
119
120 if(!(fp=FCEUD_UTF8fopen(fn,"rb"))) return(0);
121
122 FCEUX_fstat(fileno(fp),&sb);
123 len = sb.st_size;
124 buf = (char*)FCEU_dmalloc(len); //mbg merge 7/17/06 added cast
125 if ( fread(buf, 1, len, fp) != static_cast<size_t>(len) )
126 {
127 FCEU_printf("Warning: FCEUNET_SendFile failed to load complete file.\n");
128 }
129 fclose(fp);
130
131 cbuf = (char*)FCEU_dmalloc(4 + len + len / 1000 + 12); //mbg merge 7/17/06 added cast
132 FCEU_en32lsb((uint8*)cbuf, len); //mbg merge 7/17/06 added cast
133 compress2((uint8*)cbuf + 4, &clen, (uint8*)buf, len, 7); //mbg merge 7/17/06 added casts
134 free(buf);
135
136 //printf("Sending file: %s, %d, %d\n",fn,len,clen);
137
138 len = clen + 4;
139
140 if(!FCEUNET_SendCommand(cmd,len))
141 {
142 free(cbuf);
143 return(0);
144 }
145 if(!FCEUD_SendData(cbuf, len))
146 {
147 NetError();
148 free(cbuf);
149 return(0);
150 }
151 free(cbuf);
152
153 return(1);
154}
155
156static FILE *FetchFile(uint32 remlen)
157{

Callers 1

FCEUI_LoadStateFunction · 0.85

Calls 8

FCEU_dmallocFunction · 0.85
FCEU_printfFunction · 0.85
FCEU_en32lsbFunction · 0.85
compress2Function · 0.85
FCEUNET_SendCommandFunction · 0.85
NetErrorFunction · 0.85
FCEUD_UTF8fopenFunction · 0.70
FCEUD_SendDataFunction · 0.50

Tested by

no test coverage detected