summaryrefslogtreecommitdiff
path: root/navit/file.c
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2011-05-09 11:54:45 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2011-05-09 11:54:45 +0000
commit2ca3b10f58435d540de5e5cf0f6760a9ebd585ee (patch)
tree4fb85dc9f3d92b9391001dd2a44acddff808c24f /navit/file.c
parent445005a3977f879934b21ed9d7b608d09ff797a3 (diff)
downloadnavit-2ca3b10f58435d540de5e5cf0f6760a9ebd585ee.tar.gz
Fix:Core:MSVC fixes
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@4472 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/file.c')
-rw-r--r--navit/file.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/navit/file.c b/navit/file.c
index 8ed34baa2..e6b84fd95 100644
--- a/navit/file.c
+++ b/navit/file.c
@@ -31,7 +31,9 @@
#endif /* _MSC_VER */
#include <string.h>
#include <fcntl.h>
+#ifndef HAVE_API_WIN32_BASE
#include <sys/stat.h>
+#endif
#include <sys/mman.h>
#include <stdio.h>
#include <stdlib.h>
@@ -49,6 +51,9 @@
#include <sys/socket.h>
#include <netdb.h>
#endif
+#ifdef HAVE_API_WIN32_CE
+#include "libc.h"
+#endif
extern char *version;
@@ -218,7 +223,6 @@ file_http_header(struct file *f, char *header)
struct file *
file_create(char *name, struct attr **options)
{
- struct stat stat;
struct file *file= g_new0(struct file,1);
struct attr *attr;
int open_flags=O_LARGEFILE|O_BINARY;
@@ -241,8 +245,7 @@ file_create(char *name, struct attr **options)
return NULL;
}
dbg(1,"fd=%d\n", file->fd);
- fstat(file->fd, &stat);
- file->size=stat.st_size;
+ file->size=lseek(file->fd, 0, SEEK_END);
dbg(1,"size="LONGLONG_FMT"\n", file->size);
file->name_id = (int)atom(name);
}
@@ -270,21 +273,27 @@ file_create_url(char *url)
int file_is_dir(char *name)
{
+#ifndef HAVE_API_WIN32_BASE
struct stat buf;
if (! stat(name, &buf)) {
return S_ISDIR(buf.st_mode);
}
+#endif
return 0;
}
int file_is_reg(char *name)
{
+#ifndef HAVE_API_WIN32_BASE
struct stat buf;
if (! stat(name, &buf)) {
return S_ISREG(buf.st_mode);
}
return 0;
+#else
+ return 1;
+#endif
}
long long
@@ -443,7 +452,7 @@ file_data_read_special(struct file *file, int size, int *size_ret)
dbg(1,"checking header\n");
if ((hdr=file_http_header_end(file->buffer, file->buffer_len))) {
hdr[-1]='\0';
- dbg(1,"found %s (%d bytes)\n",file->buffer,sizeof(file->buffer));
+ dbg(1,"found %s (%d bytes)\n",file->buffer,strlen(file->buffer));
file_process_headers(file, file->buffer);
file_shift_buffer(file, hdr-file->buffer);
file->requests--;
@@ -663,9 +672,10 @@ file_data_free(struct file *file, unsigned char *data)
int
file_exists(char const *name)
{
- struct stat buf;
- if (! stat(name, &buf))
- return 1;
+ int fd=open(name, O_RDONLY);
+ if (fd == -1)
+ return 0;
+ close(fd);
return 0;
}