| | @@ -29,10 +29,13 @@ |
| 29 | 29 | ** |
| 30 | 30 | */ |
| 31 | 31 | #include "config.h" |
| 32 | 32 | #if ! defined(_WIN32) |
| 33 | 33 | # include <pwd.h> |
| 34 | +# if defined(__CYGWIN__) |
| 35 | +# include <sys/cygwin.h> |
| 36 | +# endif |
| 34 | 37 | #endif |
| 35 | 38 | #include <sqlite3.h> |
| 36 | 39 | #include <sys/types.h> |
| 37 | 40 | #include <sys/stat.h> |
| 38 | 41 | #include <unistd.h> |
| | @@ -793,20 +796,29 @@ |
| 793 | 796 | */ |
| 794 | 797 | void db_open_config(int useAttach){ |
| 795 | 798 | char *zDbName; |
| 796 | 799 | const char *zHome; |
| 797 | 800 | if( g.configOpen ) return; |
| 798 | | -#if defined(_WIN32) |
| 801 | +#if defined(_WIN32) || defined(__CYGWIN__) |
| 799 | 802 | zHome = fossil_getenv("LOCALAPPDATA"); |
| 800 | 803 | if( zHome==0 ){ |
| 801 | 804 | zHome = fossil_getenv("APPDATA"); |
| 802 | 805 | if( zHome==0 ){ |
| 803 | 806 | char *zDrive = fossil_getenv("HOMEDRIVE"); |
| 804 | 807 | zHome = fossil_getenv("HOMEPATH"); |
| 805 | 808 | if( zDrive && zHome ) zHome = mprintf("%s%s", zDrive, zHome); |
| 806 | 809 | } |
| 807 | 810 | } |
| 811 | +#if defined(__CYGWIN__) |
| 812 | + if( zHome!=0 ){ |
| 813 | + /* We now have the win32 path, but we need the Cygwin equivalent */ |
| 814 | + ssize_t size = cygwin_conv_path(CCP_WIN_A_TO_POSIX, zHome, 0, 0); |
| 815 | + char *converted = fossil_malloc(size); |
| 816 | + cygwin_conv_path(CCP_WIN_A_TO_POSIX, zHome, converted, size); |
| 817 | + zHome = converted; |
| 818 | + } |
| 819 | +#endif |
| 808 | 820 | if( zHome==0 ){ |
| 809 | 821 | fossil_fatal("cannot locate home directory - " |
| 810 | 822 | "please set the LOCALAPPDATA or APPDATA or HOMEPATH " |
| 811 | 823 | "environment variables"); |
| 812 | 824 | } |
| | @@ -824,11 +836,11 @@ |
| 824 | 836 | if( access(zHome, W_OK) ){ |
| 825 | 837 | fossil_fatal("home directory %s must be writeable", zHome); |
| 826 | 838 | } |
| 827 | 839 | #endif |
| 828 | 840 | g.zHome = mprintf("%/", zHome); |
| 829 | | -#if defined(_WIN32) |
| 841 | +#if defined(_WIN32) || defined(__CYGWIN__) |
| 830 | 842 | /* . filenames give some window systems problems and many apps problems */ |
| 831 | 843 | zDbName = mprintf("%//_fossil", zHome); |
| 832 | 844 | #else |
| 833 | 845 | zDbName = mprintf("%s/.fossil", zHome); |
| 834 | 846 | #endif |
| | @@ -882,10 +894,11 @@ |
| 882 | 894 | lsize = file_size(zDbName); |
| 883 | 895 | if( lsize%1024!=0 || lsize<4096 ) return 0; |
| 884 | 896 | db_open_or_attach(zDbName, "localdb", 0); |
| 885 | 897 | zVFileDef = db_text(0, "SELECT sql FROM %s.sqlite_master" |
| 886 | 898 | " WHERE name=='vfile'", db_name("localdb")); |
| 899 | + if( zVFileDef==0 ) return 0; |
| 887 | 900 | |
| 888 | 901 | /* If the "isexe" column is missing from the vfile table, then |
| 889 | 902 | ** add it now. This code added on 2010-03-06. After all users have |
| 890 | 903 | ** upgraded, this code can be safely deleted. |
| 891 | 904 | */ |
| | @@ -1980,11 +1993,11 @@ |
| 1980 | 1993 | if( !allowNested && db_open_local() ){ |
| 1981 | 1994 | fossil_panic("already within an open tree rooted at %s", g.zLocalRoot); |
| 1982 | 1995 | } |
| 1983 | 1996 | file_canonical_name(g.argv[2], &path, 0); |
| 1984 | 1997 | db_open_repository(blob_str(&path)); |
| 1985 | | -#if defined(_WIN32) |
| 1998 | +#if defined(_WIN32) || defined(__CYGWIN__) |
| 1986 | 1999 | # define LOCALDB_NAME "./_FOSSIL_" |
| 1987 | 2000 | #else |
| 1988 | 2001 | # define LOCALDB_NAME "./.fslckout" |
| 1989 | 2002 | #endif |
| 1990 | 2003 | db_init_database(LOCALDB_NAME, zLocalSchema, |
| 1991 | 2004 | |