/* File IO for GNU Emacs.
- Copyright (C) 1985, 1986, 1987, 1988 Free Software Foundation, Inc.
+ Copyright (C) 1985, 1986, 1987, 1988, 1992 Free Software Foundation, Inc.
This file is part of GNU Emacs.
GNU Emacs is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
+the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Emacs is distributed in the hope that it will be useful,
along with GNU Emacs; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+#include "config.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#endif
-#include "config.h"
#include "lisp.h"
#include "buffer.h"
#include "window.h"
/* Process as Unix format: just remove any final slash.
But leave "/" unchanged; do not change it to "". */
strcpy (dst, src);
- if (dst[slen - 1] == '/' && slen > 1)
+ if (slen > 1 && dst[slen - 1] == '/')
dst[slen - 1] = 0;
return 1;
}
#ifdef VMS
|| nm[1] == ':'
#endif /* VMS */
- || nm[1] == 0)/* ~/filename */
+ || nm[1] == 0)/* ~ by itself */
{
if (!(newdir = (unsigned char *) egetenv ("HOME")))
newdir = (unsigned char *) "";
o [p - nm] = 0;
pw = (struct passwd *) getpwnam (o + 1);
- if (!pw)
- error ("\"%s\" isn't a registered user", o + 1);
-
+ if (pw)
+ {
+ newdir = (unsigned char *) pw -> pw_dir;
#ifdef VMS
- nm = p + 1; /* skip the terminator */
+ nm = p + 1; /* skip the terminator */
#else
- nm = p;
+ nm = p;
#endif /* VMS */
- newdir = (unsigned char *) pw -> pw_dir;
+ }
+
+ /* If we don't find a user of that name, leave the name
+ unchanged; don't move nm forward to p. */
}
if (nm[0] != '/'
return make_string (target, o - target);
}
#if 0
-DEFUN ("expand-file-name", Fexpand_file_name, Sexpand_file_name, 1, 2, 0,
+/* Changed this DEFUN to a DEAFUN, so as not to confuse `make-docfile'.
+DEAFUN ("expand-file-name", Fexpand_file_name, Sexpand_file_name, 1, 2, 0,
"Convert FILENAME to absolute, and canonicalize it.\n\
Second arg DEFAULT is directory to start with if FILENAME is relative\n\
(does not start with slash); if DEFAULT is nil or missing,\n\
return Qnil;
}
-DEFUN ("remove-directory", Fremove_directory, Sremove_directory, 1, 1, "FRemove directory: ",
- "Remove a directory. One argument, a file name string.")
+DEFUN ("delete-directory", Fdelete_directory, Sdelete_directory, 1, 1, "FDelete directory: ",
+ "Delete a directory. One argument, a file name string.")
(dirname)
Lisp_Object dirname;
{
unless optional third argument OK-IF-ALREADY-EXISTS is non-nil.\n\
A number as third arg means request confirmation if NEWNAME already exists.\n\
This happens for interactive use with M-x.")
- (filename, newname, ok_if_already_exists)
- Lisp_Object filename, newname, ok_if_already_exists;
+ (filename, linkname, ok_if_already_exists)
+ Lisp_Object filename, linkname, ok_if_already_exists;
{
#ifdef NO_ARG_ARRAY
Lisp_Object args[2];
#endif
struct gcpro gcpro1, gcpro2;
- GCPRO2 (filename, newname);
+ GCPRO2 (filename, linkname);
CHECK_STRING (filename, 0);
- CHECK_STRING (newname, 1);
+ CHECK_STRING (linkname, 1);
#if 0 /* This made it impossible to make a link to a relative name. */
filename = Fexpand_file_name (filename, Qnil);
#endif
- newname = Fexpand_file_name (newname, Qnil);
+ linkname = Fexpand_file_name (linkname, Qnil);
if (NILP (ok_if_already_exists)
|| XTYPE (ok_if_already_exists) == Lisp_Int)
- barf_or_query_if_file_exists (newname, "make it a link",
+ barf_or_query_if_file_exists (linkname, "make it a link",
XTYPE (ok_if_already_exists) == Lisp_Int);
- if (0 > symlink (XSTRING (filename)->data, XSTRING (newname)->data))
+ if (0 > symlink (XSTRING (filename)->data, XSTRING (linkname)->data))
{
/* If we didn't complain already, silently delete existing file. */
if (errno == EEXIST)
{
unlink (XSTRING (filename)->data);
- if (0 <= symlink (XSTRING (filename)->data, XSTRING (newname)->data))
+ if (0 <= symlink (XSTRING (filename)->data, XSTRING (linkname)->data))
return Qnil;
}
#ifdef NO_ARG_ARRAY
args[0] = filename;
- args[1] = newname;
+ args[1] = linkname;
report_file_error ("Making symbolic link", Flist (2, args));
#else
report_file_error ("Making symbolic link", Flist (2, &filename));
return mask;
}
+#ifdef unix
+
+DEFUN ("unix-sync", Funix_sync, Sunix_sync, 0, 0, "",
+ "Tell Unix to finish all pending disk updates.")
+ ()
+{
+ sync ();
+ return Qnil;
+}
+
+#endif /* unix */
+
DEFUN ("file-newer-than-file-p", Ffile_newer_than_file_p, Sfile_newer_than_file_p, 2, 2, 0,
"Return t if file FILE1 is newer than file FILE2.\n\
If FILE1 does not exist, the answer is nil;\n\
record_unwind_protect (close_file_unwind, make_number (fd));
+#ifdef S_IFSOCK
+ /* This code will need to be changed in order to work on named
+ pipes, and it's probably just not worth it. So we should at
+ least signal an error. */
+ if ((st.st_mode & S_IFMT) == S_IFSOCK)
+ Fsignal (Qfile_error,
+ Fcons (build_string ("reading from named pipe"),
+ Fcons (filename, Qnil)));
+#endif
+
/* Supposedly happens on VMS. */
if (st.st_size < 0)
error ("File size is negative");
+
{
register Lisp_Object temp;
ring_bell ();
message ("Autosaving...error for %s", name);
- Fsleep_for (make_number (1));
+ Fsleep_for (make_number (1), Qnil);
message ("Autosaving...error!for %s", name);
- Fsleep_for (make_number (1));
+ Fsleep_for (make_number (1), Qnil);
message ("Autosaving...error for %s", name);
- Fsleep_for (make_number (1));
+ Fsleep_for (make_number (1), Qnil);
return Qnil;
}
so that your editing is not lost if the system crashes.\n\
This file is not the file you visited; that changes only when you save.\n\n\
Non-nil first argument means do not print any message if successful.\n\
-Non-nil second argumet means save only current buffer.")
+Non-nil second argument means save only current buffer.")
(nomsg)
Lisp_Object nomsg;
{
defsubr (&Ssubstitute_in_file_name);
defsubr (&Scopy_file);
defsubr (&Smake_directory);
- defsubr (&Sremove_directory);
+ defsubr (&Sdelete_directory);
defsubr (&Sdelete_file);
defsubr (&Srename_file);
defsubr (&Sadd_name_to_file);
defsubr (&Sread_file_name_internal);
defsubr (&Sread_file_name);
+
+ defsubr (&Sunix_sync);
}