/* File IO for GNU Emacs.
- Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, 1996,
- 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+
+Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, 1996, 1997,
+ 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+ 2009, 2010, 2011 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#include <config.h>
#include <limits.h>
-
-#ifdef HAVE_FCNTL_H
#include <fcntl.h>
-#endif
-
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef WINDOWSNT
#define NOMINMAX 1
#include <windows.h>
-#include <stdlib.h>
#include <fcntl.h>
#endif /* not WINDOWSNT */
#include "msdos.h"
#include <sys/param.h>
#include <fcntl.h>
-#include <string.h>
#endif
#ifdef DOS_NT
#endif
#include "commands.h"
-extern int use_dialog_box;
-extern int use_file_dialog;
-
-#ifndef O_WRONLY
-#define O_WRONLY 1
-#endif
-
-#ifndef O_RDONLY
-#define O_RDONLY 0
-#endif
#ifndef S_ISLNK
# define lstat stat
/* Whether or not to continue auto-saving after a large deletion. */
Lisp_Object Vauto_save_include_big_deletions;
-/* On NT, specifies the directory separator character, used (eg.) when
- expanding file names. This can be bound to / or \. */
-Lisp_Object Vdirectory_sep_char;
-
#ifdef HAVE_FSYNC
/* Nonzero means skip the call to fsync in Fwrite-region. */
int write_region_inhibit_fsync;
/* Lisp function for recursively deleting directories. */
Lisp_Object Qdelete_directory;
-extern Lisp_Object Vuser_login_name;
-
#ifdef WINDOWSNT
extern Lisp_Object Vw32_get_true_file_attributes;
#endif
-extern int minibuf_level;
-
-extern int minibuffer_auto_raise;
-
/* These variables describe handlers that have "already" had a chance
to handle the current operation.
as bad as (and in many cases worse than) throwing the
error, or to ignore the error, which will likely result
in looping through 225307 stat's, which is not only
- dog-slow, but also useless since it will fallback to
- the errow below, anyway. */
+ dog-slow, but also useless since eventually nil would
+ have to be returned anyway. */
report_file_error ("Cannot create temporary name for prefix",
Fcons (prefix, Qnil));
/* not reached */
}
}
-
- error ("Cannot create temporary name for prefix `%s'",
- SDATA (prefix));
- return Qnil;
}
Second arg DEFAULT-DIRECTORY is directory to start with if NAME is relative
\(does not start with slash or tilde); if DEFAULT-DIRECTORY is nil or missing,
the current buffer's value of `default-directory' is used.
+NAME should be a string that is a valid file name for the underlying
+filesystem.
File name components that are `.' are removed, and
so are file name components followed by `..', along with the `..' itself;
note that these simplifications are done without checking the resulting
file names in the file system.
+Multiple consecutive slashes are collapsed into a single slash,
+except at the beginning of the file name when they are significant (e.g.,
+UNC file names on MS-Windows.)
An initial `~/' expands to your home directory.
An initial `~USER/' expands to USER's home directory.
See also the function `substitute-in-file-name'.
For technical reasons, this function can return correct but
non-intuitive results for the root directory; for instance,
\(expand-file-name ".." "/") returns "/..". For this reason, use
-(directory-file-name (file-name-directory dirname)) to traverse a
+\(directory-file-name (file-name-directory dirname)) to traverse a
filesystem tree, not (expand-file-name ".." dirname). */)
(Lisp_Object name, Lisp_Object default_directory)
{
To avoid this, we set default_directory to the root of the
current drive. */
- extern char *emacs_root_dir (void);
-
default_directory = build_string (emacs_root_dir ());
#else
default_directory = build_string ("/");
/* Get past ~ to user */
unsigned char *user = nm + 1;
/* Find end of name. */
- unsigned char *ptr = (unsigned char *) index (user, '/');
+ unsigned char *ptr = (unsigned char *) strchr (user, '/');
int len = ptr ? ptr - user : strlen (user);
/* Copy the user name into temp storage. */
o = (unsigned char *) alloca (len + 1);
If QUICK is nonzero, we ask for y or n, not yes or no. */
void
-barf_or_query_if_file_exists (Lisp_Object absname, unsigned char *querystring, int interactive, struct stat *statptr, int quick)
+barf_or_query_if_file_exists (Lisp_Object absname, const unsigned char *querystring, int interactive, struct stat *statptr, int quick)
{
register Lisp_Object tem, encoded_filename;
struct stat statbuf;
tem = format2 ("File %s already exists; %s anyway? ",
absname, build_string (querystring));
if (quick)
- tem = Fy_or_n_p (tem);
+ tem = call1 (intern ("y-or-n-p"), tem);
else
tem = do_yes_or_no_p (tem);
UNGCPRO;
/* Return nonzero if file FILENAME exists and can be written. */
static int
-check_writable (char *filename)
+check_writable (const char *filename)
{
#ifdef MSDOS
struct stat st;
while (valsize >= bufsize);
val = make_string (buf, valsize);
- if (buf[0] == '/' && index (buf, ':'))
+ if (buf[0] == '/' && strchr (buf, ':'))
val = concat2 (build_string ("/:"), val);
xfree (buf);
val = DECODE_FILE (val);
return value;
}
\f
-extern int lisp_time_argument (Lisp_Object, time_t *, int *);
DEFUN ("set-file-times", Fset_file_times, Sset_file_times, 1, 2, 0,
doc: /* Set times of file FILENAME to TIME.
}
\f
DEFUN ("verify-visited-file-modtime", Fverify_visited_file_modtime,
- Sverify_visited_file_modtime, 1, 1, 0,
+ Sverify_visited_file_modtime, 0, 1, 0,
doc: /* Return t if last mod time of BUF's visited file matches what BUF records.
This means that the file has not been changed since it was visited or saved.
+If BUF is omitted or nil, it defaults to the current buffer.
See Info node `(elisp)Modification Time' for more details. */)
(Lisp_Object buf)
{
Lisp_Object handler;
Lisp_Object filename;
- CHECK_BUFFER (buf);
- b = XBUFFER (buf);
+ if (NILP (buf))
+ b = current_buffer;
+ else
+ {
+ CHECK_BUFFER (buf);
+ b = XBUFFER (buf);
+ }
if (!STRINGP (b->filename)) return Qt;
if (b->modtime == 0) return Qt;
static Lisp_Object
do_auto_save_unwind (Lisp_Object arg) /* used as unwind-protect function */
-
+
{
FILE *stream = (FILE *) XSAVE_VALUE (arg)->pointer;
auto_saving = 0;
static Lisp_Object
do_auto_save_unwind_1 (Lisp_Object value) /* used as unwind-protect function */
-
+
{
minibuffer_auto_raise = XINT (value);
return Qnil;
defsubr (&Sunix_sync);
#endif
}
-
-/* arch-tag: 64ba3fd7-f844-4fb2-ba4b-427eb928786c
- (do not change this comment) */