Skip to content

Commit

Permalink
lowercase filename for user logs #47
Browse files Browse the repository at this point in the history
  • Loading branch information
HarpyWar committed Aug 25, 2014
1 parent f493055 commit 15d90e3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/bnetd/userlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>

#include "compat/strcasecmp.h"
#include "compat/snprintf.h"
Expand Down Expand Up @@ -235,9 +236,12 @@ namespace pvpgn
{
char * filepath;

// lowercase username
std::string lusername = std::string(username);
std::transform(lusername.begin(), lusername.end(), lusername.begin(), ::tolower);
// get first 3 symbols of account and use it in path
// it will improve performance with large count of files
std::string dir_prefix = std::string(username).substr(0, 3);
std::string dir_prefix = lusername.substr(0, 3);

filepath = buildpath(prefs_get_userlogdir(), dir_prefix.c_str());
// create directories in path
Expand All @@ -250,7 +254,7 @@ namespace pvpgn
eventlog(eventlog_level_info, __FUNCTION__, "created user directory: %s", filepath);
}
}
filepath = buildpath(filepath, username);
filepath = buildpath(filepath, lusername.c_str());
std::strcat(filepath, ".log");

return filepath;
Expand Down

0 comments on commit 15d90e3

Please sign in to comment.