/* Various utility functions.
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+ 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
+ Inc.
This file is part of GNU Wget.
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
+#include <unistd.h>
#ifdef HAVE_MMAP
# include <sys/mman.h>
#endif
#ifdef HAVE_UTIME_H
# include <utime.h>
#endif
-#ifdef HAVE_SYS_UTIME_H
-# include <sys/utime.h>
-#endif
#include <errno.h>
#include <fcntl.h>
#include <assert.h>
#include <stdarg.h>
#include <locale.h>
+#include <sys/time.h>
+
+
/* For TIOCGWINSZ and friends: */
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
void
touch (const char *file, time_t tm)
{
-#ifdef HAVE_STRUCT_UTIMBUF
- struct utimbuf times;
-#else
- struct {
- time_t actime;
- time_t modtime;
- } times;
-#endif
- times.modtime = tm;
- times.actime = time (NULL);
- if (utime (file, ×) == -1)
- logprintf (LOG_NOTQUIET, "utime(%s): %s\n", file, strerror (errno));
+ struct timeval timevals[2];
+
+ timevals[0].tv_sec = time (NULL);
+ timevals[0].tv_usec = 0L;
+ timevals[1].tv_sec = tm;
+ timevals[1].tv_usec = 0L;
+
+ if (utimes (file, timevals) == -1)
+ logprintf (LOG_NOTQUIET, "utimes(%s): %s\n", file, strerror (errno));
}
/* Checks if FILE is a symbolic link, and removes it if it is. Does
zero-terminated, and you should *not* read or write beyond the [0,
length) range of characters.
- After you are done with the file contents, call read_file_free to
+ After you are done with the file contents, call wget_read_file_free to
release the memory.
Depending on the operating system and the type of file that is
- being read, read_file() either mmap's the file into memory, or
+ being read, wget_read_file() either mmap's the file into memory, or
reads the file into the core using read().
If file is named "-", fileno(stdin) is used for reading instead.
If you want to read from a real file named "-", use "./-" instead. */
struct file_memory *
-read_file (const char *file)
+wget_read_file (const char *file)
{
int fd;
struct file_memory *fm;
memory needed to hold the FM structure itself. */
void
-read_file_free (struct file_memory *fm)
+wget_read_file_free (struct file_memory *fm)
{
#ifdef HAVE_MMAP
if (fm->mmap_p)