MCPcopy Create free account
hub / github.com/acl-dev/acl / saveFile

Method saveFile

lib_acl_cpp/samples/websocket/upload_server/http_servlet.cpp:241–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239}
240
241bool http_servlet::saveFile(acl::websocket& in, const acl::string& filename,
242 long long len)
243{
244 acl::string filepath, tmppath;
245 filepath << var_cfg_upload_path << "/" << filename;
246 tmppath << filepath << ".tmp";
247 printf("%s, %s\n", tmppath.c_str(), filepath.c_str());
248
249 acl::ofstream fp;
250 if (fp.open_trunc(tmppath) == false)
251 {
252 printf("open_write %s error %s\r\n",
253 tmppath.c_str(), acl::last_serror());
254 return false;
255 }
256
257 if (saveFile(in, fp, len) == false)
258 {
259 fp.remove();
260 return false;
261 }
262
263 fp.close();
264 if (fp.rename(tmppath, filepath) == false)
265 {
266 fp.remove();
267 logger_error("rename from %s to %s error %s",
268 tmppath.c_str(), filepath.c_str(), acl::last_serror());
269 return false;
270 }
271
272 return true;
273}
274
275bool http_servlet::saveFile(acl::websocket& in, acl::ofstream& fp,
276 long long len)

Callers

nothing calls this directly

Calls 10

renameMethod · 0.80
read_frame_headMethod · 0.80
read_frame_dataMethod · 0.80
file_pathMethod · 0.80
last_serrorFunction · 0.50
c_strMethod · 0.45
open_truncMethod · 0.45
removeMethod · 0.45
closeMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected