aboutsummaryrefslogtreecommitdiffstats
path: root/src/fileio.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fileio.c')
-rw-r--r--src/fileio.c90
1 files changed, 45 insertions, 45 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 84e32a61265..3c61ee57bf2 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -500,7 +500,7 @@ For a Unix-syntax file name, just appends a slash. */)
500 return call2 (handler, Qfile_name_as_directory, file); 500 return call2 (handler, Qfile_name_as_directory, file);
501 501
502 buf = (char *) alloca (SBYTES (file) + 10); 502 buf = (char *) alloca (SBYTES (file) + 10);
503 file_name_as_directory (buf, SDATA (file)); 503 file_name_as_directory (buf, SSDATA (file));
504 return make_specified_string (buf, -1, strlen (buf), 504 return make_specified_string (buf, -1, strlen (buf),
505 STRING_MULTIBYTE (file)); 505 STRING_MULTIBYTE (file));
506} 506}
@@ -559,7 +559,7 @@ In Unix-syntax, this function just removes the final slash. */)
559 return call2 (handler, Qdirectory_file_name, directory); 559 return call2 (handler, Qdirectory_file_name, directory);
560 560
561 buf = (char *) alloca (SBYTES (directory) + 20); 561 buf = (char *) alloca (SBYTES (directory) + 20);
562 directory_file_name (SDATA (directory), buf); 562 directory_file_name (SSDATA (directory), buf);
563 return make_specified_string (buf, -1, strlen (buf), 563 return make_specified_string (buf, -1, strlen (buf),
564 STRING_MULTIBYTE (directory)); 564 STRING_MULTIBYTE (directory));
565} 565}
@@ -935,7 +935,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
935#ifdef WINDOWSNT 935#ifdef WINDOWSNT
936 if (IS_DIRECTORY_SEP (nm[1])) 936 if (IS_DIRECTORY_SEP (nm[1]))
937 { 937 {
938 if (strcmp (nm, SDATA (name)) != 0) 938 if (strcmp (nm, SSDATA (name)) != 0)
939 name = make_specified_string (nm, -1, strlen (nm), multibyte); 939 name = make_specified_string (nm, -1, strlen (nm), multibyte);
940 } 940 }
941 else 941 else
@@ -951,7 +951,7 @@ filesystem tree, not (expand-file-name ".." dirname). */)
951 } 951 }
952 return name; 952 return name;
953#else /* not DOS_NT */ 953#else /* not DOS_NT */
954 if (strcmp (nm, SDATA (name)) == 0) 954 if (strcmp (nm, SSDATA (name)) == 0)
955 return name; 955 return name;
956 return make_specified_string (nm, -1, strlen (nm), multibyte); 956 return make_specified_string (nm, -1, strlen (nm), multibyte);
957#endif /* not DOS_NT */ 957#endif /* not DOS_NT */
@@ -1685,13 +1685,13 @@ those `/' is discarded. */)
1685 orig = make_unibyte_string (o, orig_length); 1685 orig = make_unibyte_string (o, orig_length);
1686 decoded = DECODE_FILE (orig); 1686 decoded = DECODE_FILE (orig);
1687 decoded_length = SBYTES (decoded); 1687 decoded_length = SBYTES (decoded);
1688 strncpy (x, SDATA (decoded), decoded_length); 1688 strncpy (x, SSDATA (decoded), decoded_length);
1689 x += decoded_length; 1689 x += decoded_length;
1690 1690
1691 /* If environment variable needed decoding, return value 1691 /* If environment variable needed decoding, return value
1692 needs to be multibyte. */ 1692 needs to be multibyte. */
1693 if (decoded_length != orig_length 1693 if (decoded_length != orig_length
1694 || strncmp (SDATA (decoded), o, orig_length)) 1694 || strncmp (SSDATA (decoded), o, orig_length))
1695 multibyte = 1; 1695 multibyte = 1;
1696 } 1696 }
1697 } 1697 }
@@ -1761,7 +1761,7 @@ barf_or_query_if_file_exists (Lisp_Object absname, const unsigned char *querystr
1761 1761
1762 /* stat is a good way to tell whether the file exists, 1762 /* stat is a good way to tell whether the file exists,
1763 regardless of what access permissions it has. */ 1763 regardless of what access permissions it has. */
1764 if (lstat (SDATA (encoded_filename), &statbuf) >= 0) 1764 if (lstat (SSDATA (encoded_filename), &statbuf) >= 0)
1765 { 1765 {
1766 if (! interactive) 1766 if (! interactive)
1767 xsignal2 (Qfile_already_exists, 1767 xsignal2 (Qfile_already_exists,
@@ -1859,7 +1859,7 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */)
1859 || INTEGERP (ok_if_already_exists)) 1859 || INTEGERP (ok_if_already_exists))
1860 barf_or_query_if_file_exists (newname, "copy to it", 1860 barf_or_query_if_file_exists (newname, "copy to it",
1861 INTEGERP (ok_if_already_exists), &out_st, 0); 1861 INTEGERP (ok_if_already_exists), &out_st, 0);
1862 else if (stat (SDATA (encoded_newname), &out_st) < 0) 1862 else if (stat (SSDATA (encoded_newname), &out_st) < 0)
1863 out_st.st_mode = 0; 1863 out_st.st_mode = 0;
1864 1864
1865#ifdef WINDOWSNT 1865#ifdef WINDOWSNT
@@ -1892,7 +1892,7 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */)
1892 } 1892 }
1893#else /* not WINDOWSNT */ 1893#else /* not WINDOWSNT */
1894 immediate_quit = 1; 1894 immediate_quit = 1;
1895 ifd = emacs_open (SDATA (encoded_file), O_RDONLY, 0); 1895 ifd = emacs_open (SSDATA (encoded_file), O_RDONLY, 0);
1896 immediate_quit = 0; 1896 immediate_quit = 0;
1897 1897
1898 if (ifd < 0) 1898 if (ifd < 0)
@@ -1942,7 +1942,7 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */)
1942 | (NILP (ok_if_already_exists) ? O_EXCL : 0), 1942 | (NILP (ok_if_already_exists) ? O_EXCL : 0),
1943 S_IREAD | S_IWRITE); 1943 S_IREAD | S_IWRITE);
1944#else /* not MSDOS */ 1944#else /* not MSDOS */
1945 ofd = emacs_open (SDATA (encoded_newname), 1945 ofd = emacs_open (SSDATA (encoded_newname),
1946 O_WRONLY | O_TRUNC | O_CREAT 1946 O_WRONLY | O_TRUNC | O_CREAT
1947 | (NILP (ok_if_already_exists) ? O_EXCL : 0), 1947 | (NILP (ok_if_already_exists) ? O_EXCL : 0),
1948 0666); 1948 0666);
@@ -1993,7 +1993,7 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */)
1993 EMACS_TIME atime, mtime; 1993 EMACS_TIME atime, mtime;
1994 EMACS_SET_SECS_USECS (atime, st.st_atime, 0); 1994 EMACS_SET_SECS_USECS (atime, st.st_atime, 0);
1995 EMACS_SET_SECS_USECS (mtime, st.st_mtime, 0); 1995 EMACS_SET_SECS_USECS (mtime, st.st_mtime, 0);
1996 if (set_file_times (SDATA (encoded_newname), 1996 if (set_file_times (SSDATA (encoded_newname),
1997 atime, mtime)) 1997 atime, mtime))
1998 xsignal2 (Qfile_date_error, 1998 xsignal2 (Qfile_date_error,
1999 build_string ("Cannot set file date"), newname); 1999 build_string ("Cannot set file date"), newname);
@@ -2109,7 +2109,7 @@ With a prefix argument, TRASH is nil. */)
2109 2109
2110 encoded_file = ENCODE_FILE (filename); 2110 encoded_file = ENCODE_FILE (filename);
2111 2111
2112 if (0 > unlink (SDATA (encoded_file))) 2112 if (0 > unlink (SSDATA (encoded_file)))
2113 report_file_error ("Removing old name", list1 (filename)); 2113 report_file_error ("Removing old name", list1 (filename));
2114 return Qnil; 2114 return Qnil;
2115} 2115}
@@ -2190,7 +2190,7 @@ This is what happens in interactive use with M-x. */)
2190 || INTEGERP (ok_if_already_exists)) 2190 || INTEGERP (ok_if_already_exists))
2191 barf_or_query_if_file_exists (newname, "rename to it", 2191 barf_or_query_if_file_exists (newname, "rename to it",
2192 INTEGERP (ok_if_already_exists), 0, 0); 2192 INTEGERP (ok_if_already_exists), 0, 0);
2193 if (0 > rename (SDATA (encoded_file), SDATA (encoded_newname))) 2193 if (0 > rename (SSDATA (encoded_file), SSDATA (encoded_newname)))
2194 { 2194 {
2195 if (errno == EXDEV) 2195 if (errno == EXDEV)
2196 { 2196 {
@@ -2277,8 +2277,8 @@ This is what happens in interactive use with M-x. */)
2277 barf_or_query_if_file_exists (newname, "make it a new name", 2277 barf_or_query_if_file_exists (newname, "make it a new name",
2278 INTEGERP (ok_if_already_exists), 0, 0); 2278 INTEGERP (ok_if_already_exists), 0, 0);
2279 2279
2280 unlink (SDATA (newname)); 2280 unlink (SSDATA (newname));
2281 if (0 > link (SDATA (encoded_file), SDATA (encoded_newname))) 2281 if (0 > link (SSDATA (encoded_file), SSDATA (encoded_newname)))
2282 report_file_error ("Adding new name", list2 (file, newname)); 2282 report_file_error ("Adding new name", list2 (file, newname));
2283 2283
2284 UNGCPRO; 2284 UNGCPRO;
@@ -2336,15 +2336,15 @@ This happens for interactive use with M-x. */)
2336 || INTEGERP (ok_if_already_exists)) 2336 || INTEGERP (ok_if_already_exists))
2337 barf_or_query_if_file_exists (linkname, "make it a link", 2337 barf_or_query_if_file_exists (linkname, "make it a link",
2338 INTEGERP (ok_if_already_exists), 0, 0); 2338 INTEGERP (ok_if_already_exists), 0, 0);
2339 if (0 > symlink (SDATA (encoded_filename), 2339 if (0 > symlink (SSDATA (encoded_filename),
2340 SDATA (encoded_linkname))) 2340 SSDATA (encoded_linkname)))
2341 { 2341 {
2342 /* If we didn't complain already, silently delete existing file. */ 2342 /* If we didn't complain already, silently delete existing file. */
2343 if (errno == EEXIST) 2343 if (errno == EEXIST)
2344 { 2344 {
2345 unlink (SDATA (encoded_linkname)); 2345 unlink (SSDATA (encoded_linkname));
2346 if (0 <= symlink (SDATA (encoded_filename), 2346 if (0 <= symlink (SSDATA (encoded_filename),
2347 SDATA (encoded_linkname))) 2347 SSDATA (encoded_linkname)))
2348 { 2348 {
2349 UNGCPRO; 2349 UNGCPRO;
2350 return Qnil; 2350 return Qnil;
@@ -2444,7 +2444,7 @@ Use `file-symlink-p' to test for such links. */)
2444 2444
2445 absname = ENCODE_FILE (absname); 2445 absname = ENCODE_FILE (absname);
2446 2446
2447 return (stat (SDATA (absname), &statbuf) >= 0) ? Qt : Qnil; 2447 return (stat (SSDATA (absname), &statbuf) >= 0) ? Qt : Qnil;
2448} 2448}
2449 2449
2450DEFUN ("file-executable-p", Ffile_executable_p, Sfile_executable_p, 1, 1, 0, 2450DEFUN ("file-executable-p", Ffile_executable_p, Sfile_executable_p, 1, 1, 0,
@@ -2466,7 +2466,7 @@ For a directory, this means you can access files in that directory. */)
2466 2466
2467 absname = ENCODE_FILE (absname); 2467 absname = ENCODE_FILE (absname);
2468 2468
2469 return (check_executable (SDATA (absname)) ? Qt : Qnil); 2469 return (check_executable (SSDATA (absname)) ? Qt : Qnil);
2470} 2470}
2471 2471
2472DEFUN ("file-readable-p", Ffile_readable_p, Sfile_readable_p, 1, 1, 0, 2472DEFUN ("file-readable-p", Ffile_readable_p, Sfile_readable_p, 1, 1, 0,
@@ -2503,13 +2503,13 @@ See also `file-exists-p' and `file-attributes'. */)
2503 /* Opening a fifo without O_NONBLOCK can wait. 2503 /* Opening a fifo without O_NONBLOCK can wait.
2504 We don't want to wait. But we don't want to mess wth O_NONBLOCK 2504 We don't want to wait. But we don't want to mess wth O_NONBLOCK
2505 except in the case of a fifo, on a system which handles it. */ 2505 except in the case of a fifo, on a system which handles it. */
2506 desc = stat (SDATA (absname), &statbuf); 2506 desc = stat (SSDATA (absname), &statbuf);
2507 if (desc < 0) 2507 if (desc < 0)
2508 return Qnil; 2508 return Qnil;
2509 if (S_ISFIFO (statbuf.st_mode)) 2509 if (S_ISFIFO (statbuf.st_mode))
2510 flags |= O_NONBLOCK; 2510 flags |= O_NONBLOCK;
2511#endif 2511#endif
2512 desc = emacs_open (SDATA (absname), flags, 0); 2512 desc = emacs_open (SSDATA (absname), flags, 0);
2513 if (desc < 0) 2513 if (desc < 0)
2514 return Qnil; 2514 return Qnil;
2515 emacs_close (desc); 2515 emacs_close (desc);
@@ -2537,8 +2537,8 @@ DEFUN ("file-writable-p", Ffile_writable_p, Sfile_writable_p, 1, 1, 0,
2537 return call2 (handler, Qfile_writable_p, absname); 2537 return call2 (handler, Qfile_writable_p, absname);
2538 2538
2539 encoded = ENCODE_FILE (absname); 2539 encoded = ENCODE_FILE (absname);
2540 if (stat (SDATA (encoded), &statbuf) >= 0) 2540 if (stat (SSDATA (encoded), &statbuf) >= 0)
2541 return (check_writable (SDATA (encoded)) 2541 return (check_writable (SSDATA (encoded))
2542 ? Qt : Qnil); 2542 ? Qt : Qnil);
2543 2543
2544 dir = Ffile_name_directory (absname); 2544 dir = Ffile_name_directory (absname);
@@ -2583,9 +2583,9 @@ If there is no error, returns nil. */)
2583 2583
2584 encoded_filename = ENCODE_FILE (absname); 2584 encoded_filename = ENCODE_FILE (absname);
2585 2585
2586 fd = emacs_open (SDATA (encoded_filename), O_RDONLY, 0); 2586 fd = emacs_open (SSDATA (encoded_filename), O_RDONLY, 0);
2587 if (fd < 0) 2587 if (fd < 0)
2588 report_file_error (SDATA (string), Fcons (filename, Qnil)); 2588 report_file_error (SSDATA (string), Fcons (filename, Qnil));
2589 emacs_close (fd); 2589 emacs_close (fd);
2590 2590
2591 return Qnil; 2591 return Qnil;
@@ -2629,7 +2629,7 @@ points to a nonexistent file. */)
2629 memset (buf, 0, bufsize); 2629 memset (buf, 0, bufsize);
2630 2630
2631 errno = 0; 2631 errno = 0;
2632 valsize = readlink (SDATA (filename), buf, bufsize); 2632 valsize = readlink (SSDATA (filename), buf, bufsize);
2633 if (valsize == -1) 2633 if (valsize == -1)
2634 { 2634 {
2635#ifdef ERANGE 2635#ifdef ERANGE
@@ -2678,7 +2678,7 @@ See `file-symlink-p' to distinguish symlinks. */)
2678 2678
2679 absname = ENCODE_FILE (absname); 2679 absname = ENCODE_FILE (absname);
2680 2680
2681 if (stat (SDATA (absname), &st) < 0) 2681 if (stat (SSDATA (absname), &st) < 0)
2682 return Qnil; 2682 return Qnil;
2683 return (st.st_mode & S_IFMT) == S_IFDIR ? Qt : Qnil; 2683 return (st.st_mode & S_IFMT) == S_IFDIR ? Qt : Qnil;
2684} 2684}
@@ -2746,7 +2746,7 @@ See `file-symlink-p' to distinguish symlinks. */)
2746 return (st.st_mode & S_IFMT) == S_IFREG ? Qt : Qnil; 2746 return (st.st_mode & S_IFMT) == S_IFREG ? Qt : Qnil;
2747 } 2747 }
2748#else 2748#else
2749 if (stat (SDATA (absname), &st) < 0) 2749 if (stat (SSDATA (absname), &st) < 0)
2750 return Qnil; 2750 return Qnil;
2751 return (st.st_mode & S_IFMT) == S_IFREG ? Qt : Qnil; 2751 return (st.st_mode & S_IFMT) == S_IFREG ? Qt : Qnil;
2752#endif 2752#endif
@@ -2903,7 +2903,7 @@ Return nil, if file does not exist or is not accessible. */)
2903 2903
2904 absname = ENCODE_FILE (absname); 2904 absname = ENCODE_FILE (absname);
2905 2905
2906 if (stat (SDATA (absname), &st) < 0) 2906 if (stat (SSDATA (absname), &st) < 0)
2907 return Qnil; 2907 return Qnil;
2908 2908
2909 return make_number (st.st_mode & 07777); 2909 return make_number (st.st_mode & 07777);
@@ -2933,7 +2933,7 @@ symbolic notation, like the `chmod' command from GNU Coreutils. */)
2933 2933
2934 encoded_absname = ENCODE_FILE (absname); 2934 encoded_absname = ENCODE_FILE (absname);
2935 2935
2936 if (chmod (SDATA (encoded_absname), XINT (mode)) < 0) 2936 if (chmod (SSDATA (encoded_absname), XINT (mode)) < 0)
2937 report_file_error ("Doing chmod", Fcons (absname, Qnil)); 2937 report_file_error ("Doing chmod", Fcons (absname, Qnil));
2938 2938
2939 return Qnil; 2939 return Qnil;
@@ -3000,7 +3000,7 @@ Use the current time if TIME is nil. TIME is in the format of
3000 EMACS_SET_SECS (t, sec); 3000 EMACS_SET_SECS (t, sec);
3001 EMACS_SET_USECS (t, usec); 3001 EMACS_SET_USECS (t, usec);
3002 3002
3003 if (set_file_times (SDATA (encoded_absname), t, t)) 3003 if (set_file_times (SSDATA (encoded_absname), t, t))
3004 { 3004 {
3005#ifdef DOS_NT 3005#ifdef DOS_NT
3006 struct stat st; 3006 struct stat st;
@@ -3063,12 +3063,12 @@ otherwise, if FILE2 does not exist, the answer is t. */)
3063 absname2 = ENCODE_FILE (absname2); 3063 absname2 = ENCODE_FILE (absname2);
3064 UNGCPRO; 3064 UNGCPRO;
3065 3065
3066 if (stat (SDATA (absname1), &st) < 0) 3066 if (stat (SSDATA (absname1), &st) < 0)
3067 return Qnil; 3067 return Qnil;
3068 3068
3069 mtime1 = st.st_mtime; 3069 mtime1 = st.st_mtime;
3070 3070
3071 if (stat (SDATA (absname2), &st) < 0) 3071 if (stat (SSDATA (absname2), &st) < 0)
3072 return Qt; 3072 return Qt;
3073 3073
3074 return (mtime1 > st.st_mtime) ? Qt : Qnil; 3074 return (mtime1 > st.st_mtime) ? Qt : Qnil;
@@ -3250,12 +3250,12 @@ variable `last-coding-system-used' to the coding system actually used. */)
3250 3250
3251 /* Tell stat to use expensive method to get accurate info. */ 3251 /* Tell stat to use expensive method to get accurate info. */
3252 Vw32_get_true_file_attributes = Qt; 3252 Vw32_get_true_file_attributes = Qt;
3253 total = stat (SDATA (filename), &st); 3253 total = stat (SSDATA (filename), &st);
3254 Vw32_get_true_file_attributes = tem; 3254 Vw32_get_true_file_attributes = tem;
3255 } 3255 }
3256 if (total < 0) 3256 if (total < 0)
3257#else 3257#else
3258 if (stat (SDATA (filename), &st) < 0) 3258 if (stat (SSDATA (filename), &st) < 0)
3259#endif /* WINDOWSNT */ 3259#endif /* WINDOWSNT */
3260 { 3260 {
3261 if (fd >= 0) emacs_close (fd); 3261 if (fd >= 0) emacs_close (fd);
@@ -3287,7 +3287,7 @@ variable `last-coding-system-used' to the coding system actually used. */)
3287#endif 3287#endif
3288 3288
3289 if (fd < 0) 3289 if (fd < 0)
3290 if ((fd = emacs_open (SDATA (filename), O_RDONLY, 0)) < 0) 3290 if ((fd = emacs_open (SSDATA (filename), O_RDONLY, 0)) < 0)
3291 goto badopen; 3291 goto badopen;
3292 3292
3293 /* Replacement should preserve point as it preserves markers. */ 3293 /* Replacement should preserve point as it preserves markers. */
@@ -4975,8 +4975,8 @@ e_write (int desc, Lisp_Object string, int start, int end, struct coding_system
4975 coding->produced -= 4975 coding->produced -=
4976 emacs_write (desc, 4976 emacs_write (desc,
4977 STRINGP (coding->dst_object) 4977 STRINGP (coding->dst_object)
4978 ? SDATA (coding->dst_object) 4978 ? SSDATA (coding->dst_object)
4979 : BYTE_POS_ADDR (coding->dst_pos_byte), 4979 : (char *) BYTE_POS_ADDR (coding->dst_pos_byte),
4980 coding->produced); 4980 coding->produced);
4981 4981
4982 if (coding->produced) 4982 if (coding->produced)
@@ -5021,7 +5021,7 @@ See Info node `(elisp)Modification Time' for more details. */)
5021 5021
5022 filename = ENCODE_FILE (b->filename); 5022 filename = ENCODE_FILE (b->filename);
5023 5023
5024 if (stat (SDATA (filename), &st) < 0) 5024 if (stat (SSDATA (filename), &st) < 0)
5025 { 5025 {
5026 /* If the file doesn't exist now and didn't exist before, 5026 /* If the file doesn't exist now and didn't exist before,
5027 we say that it isn't modified, provided the error is a tame one. */ 5027 we say that it isn't modified, provided the error is a tame one. */
@@ -5098,7 +5098,7 @@ An argument specifies the modification time value to use
5098 5098
5099 filename = ENCODE_FILE (filename); 5099 filename = ENCODE_FILE (filename);
5100 5100
5101 if (stat (SDATA (filename), &st) >= 0) 5101 if (stat (SSDATA (filename), &st) >= 0)
5102 { 5102 {
5103 current_buffer->modtime = st.st_mtime; 5103 current_buffer->modtime = st.st_mtime;
5104 current_buffer->modtime_size = st.st_size; 5104 current_buffer->modtime_size = st.st_size;
@@ -5155,7 +5155,7 @@ auto_save_1 (void)
5155 /* Get visited file's mode to become the auto save file's mode. */ 5155 /* Get visited file's mode to become the auto save file's mode. */
5156 if (! NILP (current_buffer->filename)) 5156 if (! NILP (current_buffer->filename))
5157 { 5157 {
5158 if (stat (SDATA (current_buffer->filename), &st) >= 0) 5158 if (stat (SSDATA (current_buffer->filename), &st) >= 0)
5159 /* But make sure we can overwrite it later! */ 5159 /* But make sure we can overwrite it later! */
5160 auto_save_mode_bits = st.st_mode | 0600; 5160 auto_save_mode_bits = st.st_mode | 0600;
5161 else if ((modes = Ffile_modes (current_buffer->filename), 5161 else if ((modes = Ffile_modes (current_buffer->filename),
@@ -5278,7 +5278,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */)
5278 UNGCPRO; 5278 UNGCPRO;
5279 } 5279 }
5280 5280
5281 stream = fopen (SDATA (listfile), "w"); 5281 stream = fopen (SSDATA (listfile), "w");
5282 } 5282 }
5283 5283
5284 record_unwind_protect (do_auto_save_unwind, 5284 record_unwind_protect (do_auto_save_unwind,