MCPcopy Create free account
hub / github.com/assaultcube/AC / filerotate

Function filerotate

source/src/stream.cpp:1120–1134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1118
1119#ifndef STANDALONE
1120void filerotate(const char *basename, const char *ext, int keepold, const char *oldformat) // rotate old logfiles
1121{
1122 char fname1[MAXSTRLEN * 2], fname2[MAXSTRLEN] = "";
1123 copystring(fname1, findfile(basename, "w"));
1124 int mid = strlen(fname1);
1125 if(!oldformat) oldformat = "-old-%d";
1126 for(; keepold >= 0; keepold--)
1127 {
1128 formatstring(fname1 + mid)(keepold ? oldformat : "", keepold);
1129 concatformatstring(fname1 + mid, ".%s", ext);
1130 if(fname2[0]) rename(fname1, fname2);
1131 else remove(fname1);
1132 copystring(fname2, fname1);
1133 }
1134}
1135#endif

Callers 3

writecfgFunction · 0.85
writeinitcfgFunction · 0.85
initclientlogFunction · 0.85

Calls 3

copystringFunction · 0.85
findfileFunction · 0.85
concatformatstringFunction · 0.85

Tested by

no test coverage detected