Diff
Not logged in

Differences From:

File src/db.c part of check-in [2bc0e2c565] - Work toward adding a tagging system. Code compiles but is incomplete and probably does not work. by drh on 2007-09-21 02:41:53. [view]

To:

File src/db.c part of check-in [c7278fd013] - Win32 port now functional except network operations. This commit was done on windows :-). See win32.txt for status of all commands. No networking commands are functional yet. All path operations are now functioning. by jnc on 2007-09-22 06:47:11. Also file src/db.c part of check-in [3c5482959c] - Merge in the w32 changes. by drh on 2007-09-22 19:43:55. [view]

@@ -34,12 +34,14 @@
 **         root of the local copy of the source tree.
 **
 */
 #include "config.h"
+#ifndef __MINGW32__
+#  include <pwd.h>
+#endif
 #include <sqlite3.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <pwd.h>
 #include <unistd.h>
 #include "db.h"
 
 #if INTERFACE
@@ -489,13 +491,29 @@
 ** it does not already exist.
 */
 void db_open_config(void){
   char *zDbName;
-  const char *zHome = getenv("HOME");
+  const char *zHome;
+#ifdef __MINGW32__
+  zHome = getenv("LOCALAPPDATA");
+  if( zHome==0 ){
+    zHome = getenv("APPDATA");
+    if( zHome==0 ){
+      zHome = getenv("HOMEPATH");
+    }
+  }
+#else
+  zHome = getenv("HOME");
+#endif
   if( zHome==0 ){
     db_err("cannot local home directory");
   }
+#ifdef __MINGW32__
+  /* . filenames give some window systems problems and many apps problems */
+  zDbName = mprintf("%s/_fossil", zHome);
+#else
   zDbName = mprintf("%s/.fossil", zHome);
+#endif
   if( g.configOpen ) return;
   if( file_size(zDbName)<1024*3 ){
     db_init_database(zDbName, zConfigSchema, (char*)0);
   }
@@ -535,13 +553,17 @@
 */
 int db_open_local(void){
   int n;
   char zPwd[2000];
+  char *zPwdConv;
   if( g.localOpen) return 1;
   if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){
     db_err("pwd too big: max %d", sizeof(zPwd)-20);
   }
   n = strlen(zPwd);
+  zPwdConv = mprintf("%/", zPwd);
+  strncpy(zPwd, zPwdConv, 2000-20);
+  free(zPwdConv);
   while( n>0 ){
     if( access(zPwd, W_OK) ) break;
     strcpy(&zPwd[n], "/_FOSSIL_");
     if( isValidLocalDb(zPwd) ){