mariadb/portability/toku_path.cc
Leif Walsh 84fef672e4 refs #6566 update all copyright strings to reflect an end year of 2013
git-svn-id: file:///svn/toku/tokudb@55567 c7de825b-a66e-492c-adef-691d508d4ae1
2013-04-17 00:01:35 -04:00

36 lines
1.4 KiB
C++

/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id$"
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include "toku_path.h"
#include <toku_assert.h>
#include <stdlib.h>
#include <string.h>
#include <libgen.h>
const char *toku_test_filename(const char *default_filename) {
const char *filename = getenv("TOKU_TEST_FILENAME");
if (filename == nullptr) {
filename = basename((char *) default_filename);
assert(filename != nullptr);
}
return filename;
}
char *toku_path_join(char *dest, int n, const char *base, ...) {
static const char PATHSEP = '/';
char *end = stpncpy(dest, base, TOKU_PATH_MAX);
va_list ap;
va_start(ap, base);
for (int i = 1; end - dest < TOKU_PATH_MAX && i < n; ++i) {
if (*(end - 1) != PATHSEP) {
*(end++) = PATHSEP;
}
const char *next = va_arg(ap, const char *);
end = stpncpy(end, next, TOKU_PATH_MAX - (end - dest));
}
va_end(ap);
return dest;
}