Function buildBaseFilename

Synopsis

#include <src/easylogging++.h>

static void buildBaseFilename(const std::string &fullPath, char buff[], std::size_t limit=base::consts::kSourceFilenameMaxLength, const char *separator=base::consts::kFilePathSeparator)

Description

builds base filename and puts it in buff

Source

Lines 845-858 in src/easylogging++.cc. Line 1065 in src/easylogging++.h.

void File::buildBaseFilename(const std::string& fullPath, char buff[], std::size_t limit, const char* separator) {
  const char *filename = fullPath.c_str();
  std::size_t lastSlashAt = fullPath.find_last_of(separator);
  filename += lastSlashAt ? lastSlashAt+1 : 0;
  std::size_t sizeOfFilename = strlen(filename);
  if (sizeOfFilename >= limit) {
    filename += (sizeOfFilename - limit);
    if (filename[0] != '.' && filename[1] != '.') {  // prepend if not already
      filename += 3;  // 3 = '..'
      STRCAT(buff, "..", limit);
    }
  }
  STRCAT(buff, filename, limit);
}





Add Discussion

Log in to comment