From 1383ccae9e95342f8ddc9f73bc7ca96613cd86e8 Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Sat, 27 Feb 2010 18:41:07 +0000 Subject: [PATCH] MSVC compatiblity: open() flags and S_ISDIR doesn't exist on MSVC. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18753 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/backend/xml/gnc-backend-xml.c | 12 ++++++++++-- src/engine/gnc-filepath-utils.c | 11 ++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/backend/xml/gnc-backend-xml.c b/src/backend/xml/gnc-backend-xml.c index d0131f3568..777456ef27 100644 --- a/src/backend/xml/gnc-backend-xml.c +++ b/src/backend/xml/gnc-backend-xml.c @@ -241,7 +241,11 @@ xml_session_begin(QofBackend *be_start, QofSession *session, /* Again check whether the directory can be accessed */ rc = g_stat (be->dirname, &statbuf); - if (rc != 0 || !S_ISDIR(statbuf.st_mode)) + if (rc != 0 +#ifndef _MSC_VER + || !S_ISDIR(statbuf.st_mode) +#endif + ) { /* Error on stat or if it isn't a directory means we cannot find this filename */ @@ -267,7 +271,11 @@ xml_session_begin(QofBackend *be_start, QofSession *session, LEAVE(""); return; } - if (rc == 0 && S_ISDIR(statbuf.st_mode)) + if (rc == 0 +#ifndef _MSC_VER + && S_ISDIR(statbuf.st_mode) +#endif + ) { /* FIXME: What is actually checked here? Whether the fullpath erroneously points to a directory or what? diff --git a/src/engine/gnc-filepath-utils.c b/src/engine/gnc-filepath-utils.c index e3ea2a602f..94d3c50393 100644 --- a/src/engine/gnc-filepath-utils.c +++ b/src/engine/gnc-filepath-utils.c @@ -369,7 +369,13 @@ gnc_validate_directory (const gchar *dirname) if (rc) { switch (errno) { case ENOENT: - rc = g_mkdir (dirname, S_IRWXU); /* perms = S_IRWXU = 0700 */ + rc = g_mkdir (dirname, +#ifdef G_OS_WIN32 + 0 /* The mode argument is ignored on windows */ +#else + S_IRWXU /* perms = S_IRWXU = 0700 */ +#endif + ); if (rc) { g_fprintf(stderr, _("An error occurred while creating the directory:\n" @@ -422,6 +428,8 @@ gnc_validate_directory (const gchar *dirname) dirname); exit(1); } +#ifndef G_OS_WIN32 + /* The mode argument is ignored on windows anyway */ if ((statbuf.st_mode & S_IRWXU) != S_IRWXU) { g_fprintf(stderr, _("The permissions are wrong on the directory\n" @@ -430,6 +438,7 @@ gnc_validate_directory (const gchar *dirname) dirname); exit(1); } +#endif } const gchar *