Skip to content

Commit

Permalink
db.cpp : tweak correction of supplied data dir path to work on windows
Browse files Browse the repository at this point in the history
also.  This needs a real fix - something a little more elegant
  • Loading branch information
U-GEIR-5ACC88A714\Administrator authored and U-GEIR-5ACC88A714\Administrator committed Aug 23, 2008
1 parent b4d9b39 commit 5599f9e
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions db/db.cpp
Expand Up @@ -767,16 +767,25 @@ void initAndListen(int listenPort, const char *dbPath, const char *appserverLoc
#endif

/*
* ensure that the dbpath ends w/ '/' as that's key in preventing things like
* /data/dbadmin.ns
* ensure that the dbpath ends with a path delim if not supplied
* @TODO - the following is embarassing - not sure of there's a clean way to
* find the platform delim
*/

char endchar = '/';
char *endstr = "/";

#if defined(_WIN32)
endchar = '\\';
endstr = "\\";
#endif

if (dbPath && dbPath[strlen(dbPath)-1] != '/') {
if (dbPath && dbPath[strlen(dbPath)-1] != endchar) {
char *t = (char *) malloc(strlen(dbPath) + 2);
strcpy(t, dbPath);
strcat(t, "/");
dbPath = t;

strcpy(t, dbPath);
strcat(t, endstr);
dbPath = t;
}

dbpath = dbPath;
Expand Down

0 comments on commit 5599f9e

Please sign in to comment.