aboutsummaryrefslogtreecommitdiffstats
path: root/src/fileio.c
diff options
context:
space:
mode:
authorPaul Eggert2011-02-22 11:30:07 -0800
committerPaul Eggert2011-02-22 11:30:07 -0800
commitae0d725005539d9259efac6a81ff8fdd45eb69a6 (patch)
treec721b530409b355281537abc7b058bdb2697ee01 /src/fileio.c
parent8d40723d1e9661840a67ca7be9c5b073526ab421 (diff)
downloademacs-ae0d725005539d9259efac6a81ff8fdd45eb69a6.tar.gz
emacs-ae0d725005539d9259efac6a81ff8fdd45eb69a6.zip
[ChangeLog]
Work around some portability problems with symlinks. * Makefile.in (GNULIB_MODULES): Add lstat, readlink, symlink. * configure.in (lstat, HAVE_LSTAT): Remove special hack. * lib/lstat.c, lib/readlink.c, lib/stat.c, lib/symlink.c: * m4/dos.m4, m4/lstat.m4, m4/readlink.m4, m4/stat.m4, m4/symlink.m4: New files, automatically generated from gnulib. * aclocal.m4, configure, lib/Makefile.in, lib/gnulib.mk: * lib/stdlib.in.h, m4/gl-comp.m4, m4/stdlib_h.m4: Regenerate. 2011-02-22 Paul Eggert <eggert@cs.ucla.edu> [src/ChangeLog] Work around some portability problems with symlinks. * fileio.c (Frename_file, Fmake_symbolic_link, Ffile_symlink_p): Simplify the code by assuming that the readlink and symlink calls exist, even if they always fail on this host. (Ffile_readable_p): Likewise, for fifos. * config.in: Regenerate.
Diffstat (limited to 'src/fileio.c')
-rw-r--r--src/fileio.c35
1 files changed, 7 insertions, 28 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 0225e0bf3a9..26006d63052 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2178,14 +2178,11 @@ This is what happens in interactive use with M-x. */)
2178 if (errno == EXDEV) 2178 if (errno == EXDEV)
2179 { 2179 {
2180 int count; 2180 int count;
2181#ifdef S_IFLNK
2182 symlink_target = Ffile_symlink_p (file); 2181 symlink_target = Ffile_symlink_p (file);
2183 if (! NILP (symlink_target)) 2182 if (! NILP (symlink_target))
2184 Fmake_symbolic_link (symlink_target, newname, 2183 Fmake_symbolic_link (symlink_target, newname,
2185 NILP (ok_if_already_exists) ? Qnil : Qt); 2184 NILP (ok_if_already_exists) ? Qnil : Qt);
2186 else 2185 else if (!NILP (Ffile_directory_p (file)))
2187#endif
2188 if (!NILP (Ffile_directory_p (file)))
2189 call4 (Qcopy_directory, file, newname, Qt, Qnil); 2186 call4 (Qcopy_directory, file, newname, Qt, Qnil);
2190 else 2187 else
2191 /* We have already prompted if it was an integer, so don't 2188 /* We have already prompted if it was an integer, so don't
@@ -2197,11 +2194,7 @@ This is what happens in interactive use with M-x. */)
2197 count = SPECPDL_INDEX (); 2194 count = SPECPDL_INDEX ();
2198 specbind (Qdelete_by_moving_to_trash, Qnil); 2195 specbind (Qdelete_by_moving_to_trash, Qnil);
2199 2196
2200 if (!NILP (Ffile_directory_p (file)) 2197 if (!NILP (Ffile_directory_p (file)) && NILP (symlink_target))
2201#ifdef S_IFLNK
2202 && NILP (symlink_target)
2203#endif
2204 )
2205 call2 (Qdelete_directory, file, Qt); 2198 call2 (Qdelete_directory, file, Qt);
2206 else 2199 else
2207 Fdelete_file (file, Qnil); 2200 Fdelete_file (file, Qnil);
@@ -2311,7 +2304,6 @@ This happens for interactive use with M-x. */)
2311 RETURN_UNGCPRO (call4 (handler, Qmake_symbolic_link, filename, 2304 RETURN_UNGCPRO (call4 (handler, Qmake_symbolic_link, filename,
2312 linkname, ok_if_already_exists)); 2305 linkname, ok_if_already_exists));
2313 2306
2314#ifdef S_IFLNK
2315 encoded_filename = ENCODE_FILE (filename); 2307 encoded_filename = ENCODE_FILE (filename);
2316 encoded_linkname = ENCODE_FILE (linkname); 2308 encoded_linkname = ENCODE_FILE (linkname);
2317 2309
@@ -2338,12 +2330,6 @@ This happens for interactive use with M-x. */)
2338 } 2330 }
2339 UNGCPRO; 2331 UNGCPRO;
2340 return Qnil; 2332 return Qnil;
2341
2342#else
2343 UNGCPRO;
2344 xsignal1 (Qfile_error, build_string ("Symbolic links are not supported"));
2345
2346#endif /* S_IFLNK */
2347} 2333}
2348 2334
2349 2335
@@ -2482,7 +2468,7 @@ See also `file-exists-p' and `file-attributes'. */)
2482 return Qnil; 2468 return Qnil;
2483#else /* not DOS_NT and not macintosh */ 2469#else /* not DOS_NT and not macintosh */
2484 flags = O_RDONLY; 2470 flags = O_RDONLY;
2485#if defined (S_IFIFO) && defined (O_NONBLOCK) 2471#ifdef O_NONBLOCK
2486 /* Opening a fifo without O_NONBLOCK can wait. 2472 /* Opening a fifo without O_NONBLOCK can wait.
2487 We don't want to wait. But we don't want to mess wth O_NONBLOCK 2473 We don't want to wait. But we don't want to mess wth O_NONBLOCK
2488 except in the case of a fifo, on a system which handles it. */ 2474 except in the case of a fifo, on a system which handles it. */
@@ -2584,6 +2570,10 @@ points to a nonexistent file. */)
2584 (Lisp_Object filename) 2570 (Lisp_Object filename)
2585{ 2571{
2586 Lisp_Object handler; 2572 Lisp_Object handler;
2573 char *buf;
2574 int bufsize;
2575 int valsize;
2576 Lisp_Object val;
2587 2577
2588 CHECK_STRING (filename); 2578 CHECK_STRING (filename);
2589 filename = Fexpand_file_name (filename, Qnil); 2579 filename = Fexpand_file_name (filename, Qnil);
@@ -2594,13 +2584,6 @@ points to a nonexistent file. */)
2594 if (!NILP (handler)) 2584 if (!NILP (handler))
2595 return call2 (handler, Qfile_symlink_p, filename); 2585 return call2 (handler, Qfile_symlink_p, filename);
2596 2586
2597#ifdef S_IFLNK
2598 {
2599 char *buf;
2600 int bufsize;
2601 int valsize;
2602 Lisp_Object val;
2603
2604 filename = ENCODE_FILE (filename); 2587 filename = ENCODE_FILE (filename);
2605 2588
2606 bufsize = 50; 2589 bufsize = 50;
@@ -2635,10 +2618,6 @@ points to a nonexistent file. */)
2635 xfree (buf); 2618 xfree (buf);
2636 val = DECODE_FILE (val); 2619 val = DECODE_FILE (val);
2637 return val; 2620 return val;
2638 }
2639#else /* not S_IFLNK */
2640 return Qnil;
2641#endif /* not S_IFLNK */
2642} 2621}
2643 2622
2644DEFUN ("file-directory-p", Ffile_directory_p, Sfile_directory_p, 1, 1, 0, 2623DEFUN ("file-directory-p", Ffile_directory_p, Sfile_directory_p, 1, 1, 0,