1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-08 18:23:01 +01:00
git/compat/mingw.c
Johannes Sixt 25fe217b86 Windows: Treat Windows style path names.
GIT's guts work with a forward slash as a path separators. We do not change
that. Rather we make sure that only "normalized" paths enter the depths
of the machinery.

We have to translate backslashes to forward slashes in the prefix and in
command line arguments. Fortunately, all of them are passed through
functions in setup.c.

A macro has_dos_drive_path() is defined that checks whether a path begins
with a drive letter+colon combination. This predicate is always false on
Unix. Another macro is_dir_sep() abstracts that a backslash is also a
directory separator on Windows.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
2008-06-23 13:30:22 +02:00

70 lines
1.3 KiB
C

#include "../git-compat-util.h"
unsigned int _CRT_fmode = _O_BINARY;
unsigned int sleep (unsigned int seconds)
{
Sleep(seconds*1000);
return 0;
}
int mkstemp(char *template)
{
char *filename = mktemp(template);
if (filename == NULL)
return -1;
return open(filename, O_RDWR | O_CREAT, 0600);
}
int gettimeofday(struct timeval *tv, void *tz)
{
return -1;
}
int poll(struct pollfd *ufds, unsigned int nfds, int timeout)
{
return -1;
}
struct tm *gmtime_r(const time_t *timep, struct tm *result)
{
/* gmtime() in MSVCRT.DLL is thread-safe, but not reentrant */
memcpy(result, gmtime(timep), sizeof(struct tm));
return result;
}
struct tm *localtime_r(const time_t *timep, struct tm *result)
{
/* localtime() in MSVCRT.DLL is thread-safe, but not reentrant */
memcpy(result, localtime(timep), sizeof(struct tm));
return result;
}
#undef getcwd
char *mingw_getcwd(char *pointer, int len)
{
int i;
char *ret = getcwd(pointer, len);
if (!ret)
return ret;
for (i = 0; pointer[i]; i++)
if (pointer[i] == '\\')
pointer[i] = '/';
return ret;
}
struct passwd *getpwuid(int uid)
{
static struct passwd p;
return &p;
}
int setitimer(int type, struct itimerval *in, struct itimerval *out)
{
return -1;
}
int sigaction(int sig, struct sigaction *in, struct sigaction *out)
{
return -1;
}