/*
* Copyright (C) 2008 Kristian Høgsberg <krh@redhat.com>
* Copyright (C) 2008 Red Hat, Inc
+ * Copyright (C) 2009 J. Ali Harlow <ali@juiblex.co.uk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include "config.h"
+
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <fcntl.h>
#include <limits.h>
#include <assert.h>
+#ifdef MSWIN_API
+#include <shlobj.h>
+#endif
#include "razor.h"
#include "razor-internal.h"
static const char system_repo_files_filename[] = "system-files.rzdb";
static const char next_repo_filename[] = "system-next.rzdb";
-static const char razor_root_path[] = "/var/lib/razor";
+#ifdef MSWIN_API
+#define RAZOR_ROOT_PATH NULL
+#else
+#define RAZOR_ROOT_PATH "/var/lib/razor"
+#endif
+static const char *razor_root_path = RAZOR_ROOT_PATH;
struct razor_root {
struct razor_set *system;
char new_path[PATH_MAX];
};
+static void
+razor_root_init(void)
+{
+#ifdef MSWIN_API
+ static char root_path[MAX_PATH];
+ if (!razor_root_path) {
+ SHGetFolderPath(NULL,
+ CSIDL_COMMON_APPDATA | CSIDL_FLAG_DONT_VERIFY, NULL, 0,
+ root_path);
+ strcat(root_path, "\\Razor");
+ razor_root_path = root_path;
+ }
+#endif
+}
+
RAZOR_EXPORT int
razor_root_create(const char *root)
{
assert (root != NULL);
+ razor_root_init();
if (root[0] == '\0') {
/* root is file system root */
} else if (stat(root, &buf) < 0) {
assert (root != NULL);
+ razor_root_init();
image = malloc(sizeof *image);
if (image == NULL)
return NULL;
assert (root != NULL);
+ razor_root_init();
snprintf(path, sizeof path, "%s%s/%s",
root, razor_root_path, system_repo_filename);
snprintf(details_path, sizeof details_path,
assert (root != NULL);
assert (next != NULL);
+ razor_root_init();
razor_set_write_to_fd(next, root->fd, RAZOR_REPO_FILE_MAIN);
root->next = next;