#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>
#include <sys/socket.h>
#include <netdb.h>
#endif
-#ifdef HAVE_API_WIN32_CE
-#include "libc.h"
-#endif
extern char *version;
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;
return NULL;
}
dbg(1,"fd=%d\n", file->fd);
- file->size=lseek(file->fd, 0, SEEK_END);
+ fstat(file->fd, &stat);
+ file->size=stat.st_size;
dbg(1,"size="LONGLONG_FMT"\n", file->size);
file->name_id = (int)atom(name);
}
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
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,strlen(file->buffer));
+ dbg(1,"found %s (%d bytes)\n",file->buffer,sizeof(file->buffer));
file_process_headers(file, file->buffer);
file_shift_buffer(file, hdr-file->buffer);
file->requests--;
int
file_exists(char const *name)
{
- int fd=open(name, O_RDONLY);
- if (fd == -1)
- return 0;
- close(fd);
- return 1;
+ struct stat buf;
+ if (! stat(name, &buf))
+ return 1;
+ return 0;
}
void