@@ -234,17 +234,17 @@ void FileTraceLogWriter::cleanupTraceFiles() {
234
234
// Rename/finalize any stray files ending in tracePartialFileSuffix for this process.
235
235
if (!tracePartialFileSuffix.empty ()) {
236
236
for (const auto & f : platform::listFiles (directory, tracePartialFileSuffix)) {
237
- if (f.substr ( 0 , processName. length () ) == processName) {
238
- renameFile (f, f.substr ( 0 , f. size () - tracePartialFileSuffix. size () ));
237
+ if (f.parent_path ( ) == processName) {
238
+ renameFile (f, f.stem ( ));
239
239
}
240
240
}
241
241
}
242
242
243
- std::vector<std::string > existingFiles = platform::listFiles (directory, extension);
244
- std::vector<std::string > existingTraceFiles;
243
+ std::vector<std::filesystem::path > existingFiles = platform::listFiles (directory, extension);
244
+ std::vector<std::filesystem::path > existingTraceFiles;
245
245
246
246
for (auto f = existingFiles.begin (); f != existingFiles.end (); ++f) {
247
- if (f->substr ( 0 , processName. length () ) == processName) {
247
+ if (f->parent_path ( ) == processName) {
248
248
existingTraceFiles.push_back (*f);
249
249
}
250
250
}
@@ -253,15 +253,15 @@ void FileTraceLogWriter::cleanupTraceFiles() {
253
253
std::sort (existingTraceFiles.begin (), existingTraceFiles.end (), std::greater<std::string>());
254
254
255
255
uint64_t runningTotal = 0 ;
256
- std::vector<std::string >::iterator fileListIterator = existingTraceFiles.begin ();
256
+ std::vector<std::filesystem::path >::iterator fileListIterator = existingTraceFiles.begin ();
257
257
258
258
while (runningTotal < maxLogsSize && fileListIterator != existingTraceFiles.end ()) {
259
- runningTotal += (fileSize (joinPath ( directory, *fileListIterator) ) + FLOW_KNOBS->ZERO_LENGTH_FILE_PAD );
259
+ runningTotal += (fileSize (directory / *fileListIterator) + FLOW_KNOBS->ZERO_LENGTH_FILE_PAD );
260
260
++fileListIterator;
261
261
}
262
262
263
263
while (fileListIterator != existingTraceFiles.end ()) {
264
- deleteFile (joinPath ( directory, *fileListIterator) );
264
+ deleteFile (directory / *fileListIterator);
265
265
++fileListIterator;
266
266
}
267
267
} catch (Error&) {
0 commit comments