comparison src/fileio.c @ 278:90d73dddcdc4 r21-0b37

Import from CVS: tag r21-0b37
author cvs
date Mon, 13 Aug 2007 10:31:29 +0200
parents 6330739388db
children 7df0dd720c89
comparison
equal deleted inserted replaced
277:cfdf3ff11843 278:90d73dddcdc4
109 109
110 int disable_auto_save_when_buffer_shrinks; 110 int disable_auto_save_when_buffer_shrinks;
111 111
112 Lisp_Object Qfile_name_handler_alist; 112 Lisp_Object Qfile_name_handler_alist;
113 113
114 Lisp_Object Vdirectory_sep_char; 114 Lisp_Object Vpath_separator;
115 115
116 /* These variables describe handlers that have "already" had a chance 116 /* These variables describe handlers that have "already" had a chance
117 to handle the current operation. 117 to handle the current operation.
118 118
119 Vinhibit_file_name_handlers is a list of file name handlers. 119 Vinhibit_file_name_handlers is a list of file name handlers.
653 DEFUN ("make-temp-name", Fmake_temp_name, 1, 1, 0, /* 653 DEFUN ("make-temp-name", Fmake_temp_name, 1, 1, 0, /*
654 Generate temporary file name starting with PREFIX. 654 Generate temporary file name starting with PREFIX.
655 The Emacs process number forms part of the result, so there is no 655 The Emacs process number forms part of the result, so there is no
656 danger of generating a name being used by another process. 656 danger of generating a name being used by another process.
657 657
658 In its current implementation, this function guarantees 262144 unique 658 In addition, this function makes an attempt to choose a name which
659 names per process per PREFIX (this is 54872 on case-insensitive 659 has no existing file. To make this work, PREFIX should be an
660 filesystems. However, if you want it to operate safely, PREFIX should 660 absolute file name.
661 have been passed through `expand-file-name'.
662 */ 661 */
663 (prefix)) 662 (prefix))
664 { 663 {
665 static char tbl[64] = { 664 static char tbl[64] = {
666 'A','B','C','D','E','F','G','H', 665 'A','B','C','D','E','F','G','H',
698 val = make_uninit_string (len + 6); 697 val = make_uninit_string (len + 6);
699 data = XSTRING_DATA (val); 698 data = XSTRING_DATA (val);
700 memcpy (data, XSTRING_DATA (prefix), len); 699 memcpy (data, XSTRING_DATA (prefix), len);
701 p = data + len; 700 p = data + len;
702 701
703 /* `val' is created by adding 6 characters to PREFIX. The first 702 /* VAL is created by adding 6 characters to PREFIX. The first three
704 three are the PID of this process, in base 64, and the second 703 are the PID of this process, in base 64, and the second three are
705 three are incremented if the file already exists. This ensures 704 incremented if the file already exists. This ensures 262144
706 262144 unique file names per PID per PREFIX. */ 705 unique file names per PID per PREFIX. */
707 706
708 pid = (unsigned)getpid (); 707 pid = (unsigned)getpid ();
709 *p++ = tbl[pid & 63], pid >>= 6; 708 *p++ = tbl[pid & 63], pid >>= 6;
710 *p++ = tbl[pid & 63], pid >>= 6; 709 *p++ = tbl[pid & 63], pid >>= 6;
711 *p++ = tbl[pid & 63], pid >>= 6; 710 *p++ = tbl[pid & 63], pid >>= 6;
727 726
728 p[0] = tbl[num & 63], num >>= 6; 727 p[0] = tbl[num & 63], num >>= 6;
729 p[1] = tbl[num & 63], num >>= 6; 728 p[1] = tbl[num & 63], num >>= 6;
730 p[2] = tbl[num & 63], num >>= 6; 729 p[2] = tbl[num & 63], num >>= 6;
731 730
732 if (stat ((const char *) data, &ignored) < 0) 731 if (stat ((CONST char *) data, &ignored) < 0)
733 { 732 {
734 /* We want to return only if errno is ENOENT. */ 733 /* We want to return only if errno is ENOENT. */
735 if (errno == ENOENT) 734 if (errno == ENOENT)
736 return val; 735 return val;
737 else 736 else
4292 delete a large chunk of the buffer and don't notice it until too late. 4291 delete a large chunk of the buffer and don't notice it until too late.
4293 Saving the buffer normally turns auto-save back on. 4292 Saving the buffer normally turns auto-save back on.
4294 */ ); 4293 */ );
4295 disable_auto_save_when_buffer_shrinks = 1; 4294 disable_auto_save_when_buffer_shrinks = 1;
4296 4295
4297 DEFVAR_LISP ("directory-sep-char", &Vdirectory_sep_char /* 4296 DEFVAR_LISP ("path-separator", &Vpath_separator /*
4298 *Directory separator character for built-in functions that return file names. 4297 *Directory separator string for built-in functions that return file names.
4299 The value should be either ?/ or ?\\ (any other value is treated as ?\\). 4298 The value should be either \"/\" or \"\\\".
4300 This variable affects the built-in functions only on Windows,
4301 on other platforms, it is initialized so that Lisp code can find out
4302 what the normal separator is.
4303 */ ); 4299 */ );
4304 Vdirectory_sep_char = make_char(DIRECTORY_SEP); 4300 Vpath_separator = build_string("X");
4305 } 4301 (XSTRING_DATA (Vpath_separator))[0] = DIRECTORY_SEP;
4302 }