comparison src/fileio.c @ 82:6a378aca36af r20-0b91

Import from CVS: tag r20-0b91
author cvs
date Mon, 13 Aug 2007 09:07:36 +0200
parents 54cc21c15cbb
children 364816949b59
comparison
equal deleted inserted replaced
81:ebca3d831cea 82:6a378aca36af
927 927
928 The EQ test avoids infinite recursion. */ 928 The EQ test avoids infinite recursion. */
929 if (! NILP (defalt) && !EQ (defalt, name) 929 if (! NILP (defalt) && !EQ (defalt, name)
930 /* This saves time in a common case. */ 930 /* This saves time in a common case. */
931 && ! (XSTRING_LENGTH (defalt) >= 3 931 && ! (XSTRING_LENGTH (defalt) >= 3
932 && IS_DIRECTORY_SEP (string_byte (XSTRING (defalt), 0)) 932 && IS_DIRECTORY_SEP (XSTRING_BYTE (defalt, 0))
933 && IS_DEVICE_SEP (string_byte (XSTRING (defalt), 1)))) 933 && IS_DEVICE_SEP (XSTRING_BYTE (defalt, 1))))
934 { 934 {
935 struct gcpro gcpro1; 935 struct gcpro gcpro1;
936 936
937 GCPRO1 (name); 937 GCPRO1 (name);
938 defalt = Fexpand_file_name (defalt, Qnil); 938 defalt = Fexpand_file_name (defalt, Qnil);
1475 } 1475 }
1476 } 1476 }
1477 1477
1478 { 1478 {
1479 int rlen = strlen (resolved_path); 1479 int rlen = strlen (resolved_path);
1480 if (elen > 0 && string_byte (XSTRING (expanded_name), elen - 1) == '/' 1480 if (elen > 0 && XSTRING_BYTE (expanded_name, elen - 1) == '/'
1481 && !(rlen > 0 && resolved_path[rlen - 1] == '/')) 1481 && !(rlen > 0 && resolved_path[rlen - 1] == '/'))
1482 { 1482 {
1483 if (rlen + 1 > countof (resolved_path)) 1483 if (rlen + 1 > countof (resolved_path))
1484 goto toolong; 1484 goto toolong;
1485 resolved_path[rlen] = '/'; 1485 resolved_path[rlen] = '/';
1736 GCPRO1 (filename); 1736 GCPRO1 (filename);
1737 abspath = Fexpand_file_name (filename, defdir); 1737 abspath = Fexpand_file_name (filename, defdir);
1738 #ifdef VMS 1738 #ifdef VMS
1739 { 1739 {
1740 Bufbyte c = 1740 Bufbyte c =
1741 string_byte (XSTRING (abspath), XSTRING_LENGTH (abspath) - 1); 1741 XSTRING_BYTE (abspath, XSTRING_LENGTH (abspath) - 1);
1742 if (c == ':' || c == ']' || c == '>') 1742 if (c == ':' || c == ']' || c == '>')
1743 abspath = Fdirectory_file_name (abspath); 1743 abspath = Fdirectory_file_name (abspath);
1744 } 1744 }
1745 #else 1745 #else
1746 /* Remove final slash, if any (unless path is root). 1746 /* Remove final slash, if any (unless path is root).
1747 stat behaves differently depending! */ 1747 stat behaves differently depending! */
1748 if (XSTRING_LENGTH (abspath) > 1 1748 if (XSTRING_LENGTH (abspath) > 1
1749 && IS_DIRECTORY_SEP (string_byte (XSTRING (abspath), 1749 && IS_DIRECTORY_SEP (XSTRING_BYTE (abspath, XSTRING_LENGTH (abspath) - 1))
1750 XSTRING_LENGTH (abspath) - 1)) 1750 && !IS_DEVICE_SEP (XSTRING_BYTE (abspath, XSTRING_LENGTH (abspath) - 2)))
1751 && !IS_DEVICE_SEP (string_byte (XSTRING (abspath),
1752 XSTRING_LENGTH (abspath) - 2)))
1753 /* We cannot take shortcuts; they might be wrong for magic file names. */ 1751 /* We cannot take shortcuts; they might be wrong for magic file names. */
1754 abspath = Fdirectory_file_name (abspath); 1752 abspath = Fdirectory_file_name (abspath);
1755 #endif 1753 #endif
1756 UNGCPRO; 1754 UNGCPRO;
1757 return abspath; 1755 return abspath;
1857 1855
1858 args[0] = newname; 1856 args[0] = newname;
1859 args[1] = Qnil; args[2] = Qnil; 1857 args[1] = Qnil; args[2] = Qnil;
1860 NGCPRO1 (*args); 1858 NGCPRO1 (*args);
1861 ngcpro1.nvars = 3; 1859 ngcpro1.nvars = 3;
1862 if (string_byte (XSTRING (newname), 1860 if (XSTRING_BYTE (newname, XSTRING_LENGTH (newname) - 1) != '/')
1863 XSTRING_LENGTH (newname) - 1) != '/')
1864 args[i++] = build_string ("/"); 1861 args[i++] = build_string ("/");
1865 args[i++] = Ffile_name_nondirectory (filename); 1862 args[i++] = Ffile_name_nondirectory (filename);
1866 newname = Fconcat (i, args); 1863 newname = Fconcat (i, args);
1867 NUNGCPRO; 1864 NUNGCPRO;
1868 } 1865 }
2258 CHECK_STRING (filename); 2255 CHECK_STRING (filename);
2259 CHECK_STRING (linkname); 2256 CHECK_STRING (linkname);
2260 /* If the link target has a ~, we must expand it to get 2257 /* If the link target has a ~, we must expand it to get
2261 a truly valid file name. Otherwise, do not expand; 2258 a truly valid file name. Otherwise, do not expand;
2262 we want to permit links to relative file names. */ 2259 we want to permit links to relative file names. */
2263 if (string_byte (XSTRING (filename), 0) == '~') /* #### Un*x-specific */ 2260 if (XSTRING_BYTE (filename, 0) == '~') /* #### Un*x-specific */
2264 filename = Fexpand_file_name (filename, Qnil); 2261 filename = Fexpand_file_name (filename, Qnil);
2265 linkname = Fexpand_file_name (linkname, Qnil); 2262 linkname = Fexpand_file_name (linkname, Qnil);
2266 2263
2267 /* If the file name has special constructs in it, 2264 /* If the file name has special constructs in it,
2268 call the corresponding file handler. */ 2265 call the corresponding file handler. */
3467 /* if fn exists, truncate to zero length */ 3464 /* if fn exists, truncate to zero length */
3468 vms_truncate (fn_data); 3465 vms_truncate (fn_data);
3469 desc = open (fn_data, O_RDWR, 0); 3466 desc = open (fn_data, O_RDWR, 0);
3470 if (desc < 0) 3467 if (desc < 0)
3471 desc = creat_copy_attrs ((STRINGP (current_buffer->filename) 3468 desc = creat_copy_attrs ((STRINGP (current_buffer->filename)
3472 ? (char *) XSTRING_DATA (current_buffer->filename) 3469 ? (char *)
3470 XSTRING_DATA (current_buffer->filename)
3473 : 0), 3471 : 0),
3474 fn_data); 3472 fn_data);
3475 } 3473 }
3476 else /* Write to temporary name and rename if no errors */ 3474 else /* Write to temporary name and rename if no errors */
3477 { 3475 {
4161 /* This function can GC */ 4159 /* This function can GC */
4162 if (gc_in_progress) 4160 if (gc_in_progress)
4163 return Qnil; 4161 return Qnil;
4164 clear_echo_area (selected_frame (), Qauto_saving, 1); 4162 clear_echo_area (selected_frame (), Qauto_saving, 1);
4165 Fding (Qt, Qauto_save_error, Qnil); 4163 Fding (Qt, Qauto_save_error, Qnil);
4166 message ("Auto-saving...error for %s", 4164 message ("Auto-saving...error for %s", XSTRING_DATA (current_buffer->name));
4167 XSTRING_DATA (current_buffer->name));
4168 Fsleep_for (make_int (1)); 4165 Fsleep_for (make_int (1));
4169 message ("Auto-saving...error!for %s", 4166 message ("Auto-saving...error!for %s", XSTRING_DATA (current_buffer->name));
4170 XSTRING_DATA (current_buffer->name));
4171 Fsleep_for (make_int (1)); 4167 Fsleep_for (make_int (1));
4172 message ("Auto-saving...error for %s", 4168 message ("Auto-saving...error for %s", XSTRING_DATA (current_buffer->name));
4173 XSTRING_DATA (current_buffer->name));
4174 Fsleep_for (make_int (1)); 4169 Fsleep_for (make_int (1));
4175 return Qnil; 4170 return Qnil;
4176 } 4171 }
4177 4172
4178 static Lisp_Object 4173 static Lisp_Object