const char *get_default_configdir()
{
#if defined(HAVE_WIN32)
-#define DEFAULT_CONFIGDIR "C:\\Documents and Settings\\All Users\\Application Data\\Bacula"
-
HRESULT hr;
static char szConfigDir[MAX_PATH + 1] = { 0 };
+ if (!p_SHGetFolderPath) {
+ bstrncpy(szConfigDir, DEFAULT_CONFIGDIR, sizeof(szConfigDir));
+ return szConfigDir;
+ }
+
if (szConfigDir[0] == '\0') {
- hr = SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, 0, szConfigDir);
+ hr = p_SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, 0, szConfigDir);
if (SUCCEEDED(hr)) {
bstrncat(szConfigDir, "\\Bacula", sizeof(szConfigDir));
bool
find_config_file(const char *config_file, char *full_path)
{
-#if defined(HAVE_WIN32)
- if (strpbrk(config_file, ":/\\") != NULL) {
+ if (first_path_separator(config_file) != NULL) {
return false;
}
-#else
- if (strchr(config_file, '/') != NULL) {
- return false;
- }
-#endif
struct stat st;
memcpy(full_path, config_dir, dir_length + 1);
- if (full_path[dir_length - 1] != '/' &&
- full_path[dir_length - 1] != '\\') {
+ if (!IsPathSeparator(full_path[dir_length - 1])) {
full_path[dir_length++] = '/';
}