Mercurial > emacs
comparison src/fileio.c @ 90228:fa0da9b57058
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-82
Merge from emacs--cvs-trunk--0
Patches applied:
* emacs--cvs-trunk--0 (patch 542-553)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 116-121)
- Merge from emacs--cvs-trunk--0
- Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Mon, 19 Sep 2005 10:20:33 +0000 |
parents | 2d92f5c9d6ae da6fcded2062 |
children | 0ca0d9181b5e |
comparison
equal
deleted
inserted
replaced
90227:10fe5fadaf89 | 90228:fa0da9b57058 |
---|---|
222 int vms_stmlf_recfm; | 222 int vms_stmlf_recfm; |
223 | 223 |
224 /* On NT, specifies the directory separator character, used (eg.) when | 224 /* On NT, specifies the directory separator character, used (eg.) when |
225 expanding file names. This can be bound to / or \. */ | 225 expanding file names. This can be bound to / or \. */ |
226 Lisp_Object Vdirectory_sep_char; | 226 Lisp_Object Vdirectory_sep_char; |
227 | |
228 #ifdef HAVE_FSYNC | |
229 /* Nonzero means skip the call to fsync in Fwrite-region. */ | |
230 int write_region_inhibit_fsync; | |
231 #endif | |
227 | 232 |
228 extern Lisp_Object Vuser_login_name; | 233 extern Lisp_Object Vuser_login_name; |
229 | 234 |
230 #ifdef WINDOWSNT | 235 #ifdef WINDOWSNT |
231 extern Lisp_Object Vw32_get_true_file_attributes; | 236 extern Lisp_Object Vw32_get_true_file_attributes; |
1058 int collapse_newdir = 1; | 1063 int collapse_newdir = 1; |
1059 int is_escaped = 0; | 1064 int is_escaped = 0; |
1060 #endif /* DOS_NT */ | 1065 #endif /* DOS_NT */ |
1061 int length; | 1066 int length; |
1062 Lisp_Object handler, result; | 1067 Lisp_Object handler, result; |
1068 int multibyte; | |
1063 | 1069 |
1064 CHECK_STRING (name); | 1070 CHECK_STRING (name); |
1065 | 1071 |
1066 /* If the file name has special constructs in it, | 1072 /* If the file name has special constructs in it, |
1067 call the corresponding file handler. */ | 1073 call the corresponding file handler. */ |
1135 UNGCPRO; | 1141 UNGCPRO; |
1136 } | 1142 } |
1137 | 1143 |
1138 name = FILE_SYSTEM_CASE (name); | 1144 name = FILE_SYSTEM_CASE (name); |
1139 nm = SDATA (name); | 1145 nm = SDATA (name); |
1146 multibyte = STRING_MULTIBYTE (name); | |
1140 | 1147 |
1141 #ifdef DOS_NT | 1148 #ifdef DOS_NT |
1142 /* We will force directory separators to be either all \ or /, so make | 1149 /* We will force directory separators to be either all \ or /, so make |
1143 a local copy to modify, even if there ends up being no change. */ | 1150 a local copy to modify, even if there ends up being no change. */ |
1144 nm = strcpy (alloca (strlen (nm) + 1), nm); | 1151 nm = strcpy (alloca (strlen (nm) + 1), nm); |
1300 { | 1307 { |
1301 #ifdef VMS | 1308 #ifdef VMS |
1302 if (index (nm, '/')) | 1309 if (index (nm, '/')) |
1303 { | 1310 { |
1304 nm = sys_translate_unix (nm); | 1311 nm = sys_translate_unix (nm); |
1305 return make_specified_string (nm, -1, strlen (nm), | 1312 return make_specified_string (nm, -1, strlen (nm), multibyte); |
1306 STRING_MULTIBYTE (name)); | |
1307 } | 1313 } |
1308 #endif /* VMS */ | 1314 #endif /* VMS */ |
1309 #ifdef DOS_NT | 1315 #ifdef DOS_NT |
1310 /* Make sure directories are all separated with / or \ as | 1316 /* Make sure directories are all separated with / or \ as |
1311 desired, but avoid allocation of a new string when not | 1317 desired, but avoid allocation of a new string when not |
1313 CORRECT_DIR_SEPS (nm); | 1319 CORRECT_DIR_SEPS (nm); |
1314 #ifdef WINDOWSNT | 1320 #ifdef WINDOWSNT |
1315 if (IS_DIRECTORY_SEP (nm[1])) | 1321 if (IS_DIRECTORY_SEP (nm[1])) |
1316 { | 1322 { |
1317 if (strcmp (nm, SDATA (name)) != 0) | 1323 if (strcmp (nm, SDATA (name)) != 0) |
1318 name = make_specified_string (nm, -1, strlen (nm), | 1324 name = make_specified_string (nm, -1, strlen (nm), multibyte); |
1319 STRING_MULTIBYTE (name)); | |
1320 } | 1325 } |
1321 else | 1326 else |
1322 #endif | 1327 #endif |
1323 /* drive must be set, so this is okay */ | 1328 /* drive must be set, so this is okay */ |
1324 if (strcmp (nm - 2, SDATA (name)) != 0) | 1329 if (strcmp (nm - 2, SDATA (name)) != 0) |
1325 { | 1330 { |
1326 char temp[] = " :"; | 1331 char temp[] = " :"; |
1327 | 1332 |
1328 name = make_specified_string (nm, -1, p - nm, | 1333 name = make_specified_string (nm, -1, p - nm, multibyte); |
1329 STRING_MULTIBYTE (name)); | |
1330 temp[0] = DRIVE_LETTER (drive); | 1334 temp[0] = DRIVE_LETTER (drive); |
1331 name = concat2 (build_string (temp), name); | 1335 name = concat2 (build_string (temp), name); |
1332 } | 1336 } |
1333 return name; | 1337 return name; |
1334 #else /* not DOS_NT */ | 1338 #else /* not DOS_NT */ |
1335 if (nm == SDATA (name)) | 1339 if (nm == SDATA (name)) |
1336 return name; | 1340 return name; |
1337 return make_specified_string (nm, -1, strlen (nm), | 1341 return make_specified_string (nm, -1, strlen (nm), multibyte); |
1338 STRING_MULTIBYTE (name)); | |
1339 #endif /* not DOS_NT */ | 1342 #endif /* not DOS_NT */ |
1340 } | 1343 } |
1341 } | 1344 } |
1342 | 1345 |
1343 /* At this point, nm might or might not be an absolute file name. We | 1346 /* At this point, nm might or might not be an absolute file name. We |
1445 && !index (nm, ':') | 1448 && !index (nm, ':') |
1446 #endif | 1449 #endif |
1447 && !newdir) | 1450 && !newdir) |
1448 { | 1451 { |
1449 newdir = SDATA (default_directory); | 1452 newdir = SDATA (default_directory); |
1453 multibyte |= STRING_MULTIBYTE (default_directory); | |
1450 #ifdef DOS_NT | 1454 #ifdef DOS_NT |
1451 /* Note if special escape prefix is present, but remove for now. */ | 1455 /* Note if special escape prefix is present, but remove for now. */ |
1452 if (newdir[0] == '/' && newdir[1] == ':') | 1456 if (newdir[0] == '/' && newdir[1] == ':') |
1453 { | 1457 { |
1454 is_escaped = 1; | 1458 is_escaped = 1; |
1710 target[1] = ':'; | 1714 target[1] = ':'; |
1711 } | 1715 } |
1712 CORRECT_DIR_SEPS (target); | 1716 CORRECT_DIR_SEPS (target); |
1713 #endif /* DOS_NT */ | 1717 #endif /* DOS_NT */ |
1714 | 1718 |
1715 result = make_specified_string (target, -1, o - target, | 1719 result = make_specified_string (target, -1, o - target, multibyte); |
1716 STRING_MULTIBYTE (name)); | |
1717 | 1720 |
1718 /* Again look to see if the file name has special constructs in it | 1721 /* Again look to see if the file name has special constructs in it |
1719 and perhaps call the corresponding file handler. This is needed | 1722 and perhaps call the corresponding file handler. This is needed |
1720 for filenames such as "/foo/../user@host:/bar/../baz". Expanding | 1723 for filenames such as "/foo/../user@host:/bar/../baz". Expanding |
1721 the ".." component gives us "/user@host:/bar/../baz" which needs | 1724 the ".." component gives us "/user@host:/bar/../baz" which needs |
5240 #ifdef HAVE_FSYNC | 5243 #ifdef HAVE_FSYNC |
5241 /* Note fsync appears to change the modtime on BSD4.2 (both vax and sun). | 5244 /* Note fsync appears to change the modtime on BSD4.2 (both vax and sun). |
5242 Disk full in NFS may be reported here. */ | 5245 Disk full in NFS may be reported here. */ |
5243 /* mib says that closing the file will try to write as fast as NFS can do | 5246 /* mib says that closing the file will try to write as fast as NFS can do |
5244 it, and that means the fsync here is not crucial for autosave files. */ | 5247 it, and that means the fsync here is not crucial for autosave files. */ |
5245 if (!auto_saving && fsync (desc) < 0) | 5248 if (!auto_saving && !write_region_inhibit_fsync && fsync (desc) < 0) |
5246 { | 5249 { |
5247 /* If fsync fails with EINTR, don't treat that as serious. */ | 5250 /* If fsync fails with EINTR, don't treat that as serious. */ |
5248 if (errno != EINTR) | 5251 if (errno != EINTR) |
5249 failure = 1, save_errno = errno; | 5252 failure = 1, save_errno = errno; |
5250 } | 5253 } |
5683 Lisp_Object error; | 5686 Lisp_Object error; |
5684 { | 5687 { |
5685 Lisp_Object args[3], msg; | 5688 Lisp_Object args[3], msg; |
5686 int i, nbytes; | 5689 int i, nbytes; |
5687 struct gcpro gcpro1; | 5690 struct gcpro gcpro1; |
5691 char *msgbuf; | |
5692 USE_SAFE_ALLOCA; | |
5688 | 5693 |
5689 ring_bell (); | 5694 ring_bell (); |
5690 | 5695 |
5691 args[0] = build_string ("Auto-saving %s: %s"); | 5696 args[0] = build_string ("Auto-saving %s: %s"); |
5692 args[1] = current_buffer->name; | 5697 args[1] = current_buffer->name; |
5693 args[2] = Ferror_message_string (error); | 5698 args[2] = Ferror_message_string (error); |
5694 msg = Fformat (3, args); | 5699 msg = Fformat (3, args); |
5695 GCPRO1 (msg); | 5700 GCPRO1 (msg); |
5696 nbytes = SBYTES (msg); | 5701 nbytes = SBYTES (msg); |
5702 SAFE_ALLOCA (msgbuf, char *, nbytes); | |
5703 bcopy (SDATA (msg), msgbuf, nbytes); | |
5697 | 5704 |
5698 for (i = 0; i < 3; ++i) | 5705 for (i = 0; i < 3; ++i) |
5699 { | 5706 { |
5700 if (i == 0) | 5707 if (i == 0) |
5701 message2 (SDATA (msg), nbytes, STRING_MULTIBYTE (msg)); | 5708 message2 (msgbuf, nbytes, STRING_MULTIBYTE (msg)); |
5702 else | 5709 else |
5703 message2_nolog (SDATA (msg), nbytes, STRING_MULTIBYTE (msg)); | 5710 message2_nolog (msgbuf, nbytes, STRING_MULTIBYTE (msg)); |
5704 Fsleep_for (make_number (1), Qnil); | 5711 Fsleep_for (make_number (1), Qnil); |
5705 } | 5712 } |
5706 | 5713 |
5707 UNGCPRO; | 5714 UNGCPRO; |
5708 return Qnil; | 5715 return Qnil; |
6653 doc: /* File name in which we write a list of all auto save file names. | 6660 doc: /* File name in which we write a list of all auto save file names. |
6654 This variable is initialized automatically from `auto-save-list-file-prefix' | 6661 This variable is initialized automatically from `auto-save-list-file-prefix' |
6655 shortly after Emacs reads your `.emacs' file, if you have not yet given it | 6662 shortly after Emacs reads your `.emacs' file, if you have not yet given it |
6656 a non-nil value. */); | 6663 a non-nil value. */); |
6657 Vauto_save_list_file_name = Qnil; | 6664 Vauto_save_list_file_name = Qnil; |
6665 | |
6666 #ifdef HAVE_FSYNC | |
6667 DEFVAR_BOOL ("write-region-inhibit-fsync", &write_region_inhibit_fsync, | |
6668 doc: /* *Non-nil means don't call fsync in `write-region'. | |
6669 This variable affects calls to `write-region' as well as save commands. | |
6670 A non-nil value may result in data loss! */); | |
6671 write_region_inhibit_fsync = 0; | |
6672 #endif | |
6658 | 6673 |
6659 defsubr (&Sfind_file_name_handler); | 6674 defsubr (&Sfind_file_name_handler); |
6660 defsubr (&Sfile_name_directory); | 6675 defsubr (&Sfile_name_directory); |
6661 defsubr (&Sfile_name_nondirectory); | 6676 defsubr (&Sfile_name_nondirectory); |
6662 defsubr (&Sunhandled_file_name_directory); | 6677 defsubr (&Sunhandled_file_name_directory); |