diff options
Diffstat (limited to 'src/fileio.c')
-rw-r--r-- | src/fileio.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/fileio.c b/src/fileio.c index 56557da6a30..906c42d9126 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -227,6 +227,11 @@ int vms_stmlf_recfm; expanding file names. This can be bound to / or \. */ Lisp_Object Vdirectory_sep_char; +#ifdef HAVE_FSYNC +/* Nonzero means skip the call to fsync in Fwrite-region. */ +int write_region_inhibit_fsync; +#endif + extern Lisp_Object Vuser_login_name; #ifdef WINDOWSNT @@ -1058,6 +1063,7 @@ See also the function `substitute-in-file-name'. */) #endif /* DOS_NT */ int length; Lisp_Object handler, result; + int multibyte; CHECK_STRING (name); @@ -1135,6 +1141,7 @@ See also the function `substitute-in-file-name'. */) name = FILE_SYSTEM_CASE (name); nm = SDATA (name); + multibyte = STRING_MULTIBYTE (name); #ifdef DOS_NT /* We will force directory separators to be either all \ or /, so make @@ -1300,8 +1307,7 @@ See also the function `substitute-in-file-name'. */) if (index (nm, '/')) { nm = sys_translate_unix (nm); - return make_specified_string (nm, -1, strlen (nm), - STRING_MULTIBYTE (name)); + return make_specified_string (nm, -1, strlen (nm), multibyte); } #endif /* VMS */ #ifdef DOS_NT @@ -1313,8 +1319,7 @@ See also the function `substitute-in-file-name'. */) if (IS_DIRECTORY_SEP (nm[1])) { if (strcmp (nm, SDATA (name)) != 0) - name = make_specified_string (nm, -1, strlen (nm), - STRING_MULTIBYTE (name)); + name = make_specified_string (nm, -1, strlen (nm), multibyte); } else #endif @@ -1323,8 +1328,7 @@ See also the function `substitute-in-file-name'. */) { char temp[] = " :"; - name = make_specified_string (nm, -1, p - nm, - STRING_MULTIBYTE (name)); + name = make_specified_string (nm, -1, p - nm, multibyte); temp[0] = DRIVE_LETTER (drive); name = concat2 (build_string (temp), name); } @@ -1332,8 +1336,7 @@ See also the function `substitute-in-file-name'. */) #else /* not DOS_NT */ if (nm == SDATA (name)) return name; - return make_specified_string (nm, -1, strlen (nm), - STRING_MULTIBYTE (name)); + return make_specified_string (nm, -1, strlen (nm), multibyte); #endif /* not DOS_NT */ } } @@ -1445,6 +1448,7 @@ See also the function `substitute-in-file-name'. */) && !newdir) { newdir = SDATA (default_directory); + multibyte |= STRING_MULTIBYTE (default_directory); #ifdef DOS_NT /* Note if special escape prefix is present, but remove for now. */ if (newdir[0] == '/' && newdir[1] == ':') @@ -1710,8 +1714,7 @@ See also the function `substitute-in-file-name'. */) CORRECT_DIR_SEPS (target); #endif /* DOS_NT */ - result = make_specified_string (target, -1, o - target, - STRING_MULTIBYTE (name)); + result = make_specified_string (target, -1, o - target, multibyte); /* Again look to see if the file name has special constructs in it and perhaps call the corresponding file handler. This is needed @@ -5300,7 +5303,7 @@ This does code conversion according to the value of Disk full in NFS may be reported here. */ /* mib says that closing the file will try to write as fast as NFS can do it, and that means the fsync here is not crucial for autosave files. */ - if (!auto_saving && fsync (desc) < 0) + if (!auto_saving && !write_region_inhibit_fsync && fsync (desc) < 0) { /* If fsync fails with EINTR, don't treat that as serious. */ if (errno != EINTR) @@ -6746,6 +6749,13 @@ shortly after Emacs reads your `.emacs' file, if you have not yet given it a non-nil value. */); Vauto_save_list_file_name = Qnil; +#ifdef HAVE_FSYNC + DEFVAR_BOOL ("write-region-inhibit-fsync", &write_region_inhibit_fsync, + doc: /* *Non-nil means don't call fsync after saving files. +Enabling this variable may result in data loss! */); + write_region_inhibit_fsync = 0; +#endif + defsubr (&Sfind_file_name_handler); defsubr (&Sfile_name_directory); defsubr (&Sfile_name_nondirectory); |