Mercurial > hg > xemacs-beta
comparison src/fileio.c @ 120:cca96a509cfe r20-1b12
Import from CVS: tag r20-1b12
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:25:29 +0200 |
parents | 9f59509498e1 |
children | 9b50b4588a93 |
comparison
equal
deleted
inserted
replaced
119:d101af7320b8 | 120:cca96a509cfe |
---|---|
411 Given a Unix syntax file name, returns a string ending in slash; | 411 Given a Unix syntax file name, returns a string ending in slash; |
412 on VMS, perhaps instead a string ending in `:', `]' or `>'. | 412 on VMS, perhaps instead a string ending in `:', `]' or `>'. |
413 */ | 413 */ |
414 (file)) | 414 (file)) |
415 { | 415 { |
416 /* This function can call lisp */ | 416 /* This function can GC. GC checked 1997.04.06. */ |
417 Bufbyte *beg; | 417 Bufbyte *beg; |
418 Bufbyte *p; | 418 Bufbyte *p; |
419 Lisp_Object handler; | 419 Lisp_Object handler; |
420 | 420 |
421 CHECK_STRING (file); | 421 CHECK_STRING (file); |
479 this is everything after the last slash, | 479 this is everything after the last slash, |
480 or the entire name if it contains no slash. | 480 or the entire name if it contains no slash. |
481 */ | 481 */ |
482 (file)) | 482 (file)) |
483 { | 483 { |
484 /* This function can call lisp */ | 484 /* This function can GC. GC checked 1997.04.06. */ |
485 Bufbyte *beg, *p, *end; | 485 Bufbyte *beg, *p, *end; |
486 Lisp_Object handler; | 486 Lisp_Object handler; |
487 | 487 |
488 CHECK_STRING (file); | 488 CHECK_STRING (file); |
489 | 489 |
515 The `call-process' and `start-process' functions use this function to | 515 The `call-process' and `start-process' functions use this function to |
516 get a current directory to run processes in. | 516 get a current directory to run processes in. |
517 */ | 517 */ |
518 (filename)) | 518 (filename)) |
519 { | 519 { |
520 /* This function can call lisp */ | 520 /* This function can GC. GC checked 1997.04.06. */ |
521 Lisp_Object handler; | 521 Lisp_Object handler; |
522 | 522 |
523 /* If the file name has special constructs in it, | 523 /* If the file name has special constructs in it, |
524 call the corresponding file handler. */ | 524 call the corresponding file handler. */ |
525 handler = Ffind_file_name_handler (filename, Qunhandled_file_name_directory); | 525 handler = Ffind_file_name_handler (filename, Qunhandled_file_name_directory); |
615 For a Unix-syntax file name, just appends a slash. | 615 For a Unix-syntax file name, just appends a slash. |
616 On VMS, converts \"[X]FOO.DIR\" to \"[X.FOO]\", etc. | 616 On VMS, converts \"[X]FOO.DIR\" to \"[X.FOO]\", etc. |
617 */ | 617 */ |
618 (file)) | 618 (file)) |
619 { | 619 { |
620 /* This function can call lisp */ | 620 /* This function can GC. GC checked 1997.04.06. */ |
621 char *buf; | 621 char *buf; |
622 Lisp_Object handler; | 622 Lisp_Object handler; |
623 | 623 |
624 CHECK_STRING (file); | 624 CHECK_STRING (file); |
625 | 625 |
801 On VMS, given a VMS-syntax directory name such as \"[X.Y]\", | 801 On VMS, given a VMS-syntax directory name such as \"[X.Y]\", |
802 it returns a file name such as \"[X]Y.DIR.1\". | 802 it returns a file name such as \"[X]Y.DIR.1\". |
803 */ | 803 */ |
804 (directory)) | 804 (directory)) |
805 { | 805 { |
806 /* This function can call lisp */ | 806 /* This function can GC. GC checked 1997.04.06. */ |
807 char *buf; | 807 char *buf; |
808 Lisp_Object handler; | 808 Lisp_Object handler; |
809 | 809 |
810 CHECK_STRING (directory); | 810 CHECK_STRING (directory); |
811 | 811 |
869 An initial `~USER/' expands to USER's home directory. | 869 An initial `~USER/' expands to USER's home directory. |
870 See also the function `substitute-in-file-name'. | 870 See also the function `substitute-in-file-name'. |
871 */ | 871 */ |
872 (name, defalt)) | 872 (name, defalt)) |
873 { | 873 { |
874 /* This function can call lisp */ | 874 /* This function can GC. GC checked 1997.04.06. */ |
875 Bufbyte *nm; | 875 Bufbyte *nm; |
876 | 876 |
877 Bufbyte *newdir, *p, *o; | 877 Bufbyte *newdir, *p, *o; |
878 int tlen; | 878 int tlen; |
879 Bufbyte *target; | 879 Bufbyte *target; |
891 int drive = -1; | 891 int drive = -1; |
892 int relpath = 0; | 892 int relpath = 0; |
893 Bufbyte *tmp, *defdir; | 893 Bufbyte *tmp, *defdir; |
894 #endif /* DOS_NT */ | 894 #endif /* DOS_NT */ |
895 Lisp_Object handler; | 895 Lisp_Object handler; |
896 struct gcpro gcpro1; | |
897 | 896 |
898 CHECK_STRING (name); | 897 CHECK_STRING (name); |
899 | 898 |
900 /* If the file name has special constructs in it, | 899 /* If the file name has special constructs in it, |
901 call the corresponding file handler. */ | 900 call the corresponding file handler. */ |
1399 No component of the resulting pathname will be a symbolic link, as | 1398 No component of the resulting pathname will be a symbolic link, as |
1400 in the realpath() function. | 1399 in the realpath() function. |
1401 */ | 1400 */ |
1402 (filename, defalt)) | 1401 (filename, defalt)) |
1403 { | 1402 { |
1404 /* This function can call lisp */ | 1403 /* This function can GC. GC checked 1997.04.06. */ |
1405 struct gcpro gcpro1; | |
1406 Lisp_Object expanded_name; | 1404 Lisp_Object expanded_name; |
1407 Lisp_Object handler; | 1405 Lisp_Object handler; |
1406 struct gcpro gcpro1; | |
1408 | 1407 |
1409 CHECK_STRING (filename); | 1408 CHECK_STRING (filename); |
1410 | 1409 |
1411 expanded_name = Fexpand_file_name (filename, defalt); | 1410 expanded_name = Fexpand_file_name (filename, defalt); |
1412 | 1411 |
1526 On VMS, `$' substitution is not done; this function does little and only | 1525 On VMS, `$' substitution is not done; this function does little and only |
1527 duplicates what `expand-file-name' does. | 1526 duplicates what `expand-file-name' does. |
1528 */ | 1527 */ |
1529 (string)) | 1528 (string)) |
1530 { | 1529 { |
1531 /* This function can call lisp */ | 1530 /* This function can GC. GC checked 1997.04.06. */ |
1532 Bufbyte *nm; | 1531 Bufbyte *nm; |
1533 | 1532 |
1534 Bufbyte *s, *p, *o, *x, *endp; | 1533 Bufbyte *s, *p, *o, *x, *endp; |
1535 Bufbyte *target = 0; | 1534 Bufbyte *target = 0; |
1536 int total = 0; | 1535 int total = 0; |
1775 | 1774 |
1776 static void | 1775 static void |
1777 barf_or_query_if_file_exists (Lisp_Object absname, CONST char *querystring, | 1776 barf_or_query_if_file_exists (Lisp_Object absname, CONST char *querystring, |
1778 int interactive, struct stat *statptr) | 1777 int interactive, struct stat *statptr) |
1779 { | 1778 { |
1780 /* This function can call lisp */ | 1779 /* This function can GC. GC checked 1997.04.06. */ |
1781 struct stat statbuf; | 1780 struct stat statbuf; |
1782 | 1781 |
1783 /* stat is a good way to tell whether the file exists, | 1782 /* stat is a good way to tell whether the file exists, |
1784 regardless of what access permissions it has. */ | 1783 regardless of what access permissions it has. */ |
1785 if (stat ((char *) XSTRING_DATA (absname), &statbuf) >= 0) | 1784 if (stat ((char *) XSTRING_DATA (absname), &statbuf) >= 0) |
1829 last-modified time as the old one. (This works on only some systems.) | 1828 last-modified time as the old one. (This works on only some systems.) |
1830 A prefix arg makes KEEP-TIME non-nil. | 1829 A prefix arg makes KEEP-TIME non-nil. |
1831 */ | 1830 */ |
1832 (filename, newname, ok_if_already_exists, keep_time)) | 1831 (filename, newname, ok_if_already_exists, keep_time)) |
1833 { | 1832 { |
1834 /* This function can call lisp */ | 1833 /* This function can GC. GC checked 1997.04.06. */ |
1835 int ifd, ofd, n; | 1834 int ifd, ofd, n; |
1836 char buf[16 * 1024]; | 1835 char buf[16 * 1024]; |
1837 struct stat st, out_st; | 1836 struct stat st, out_st; |
1838 Lisp_Object handler; | 1837 Lisp_Object handler; |
1839 int speccount = specpdl_depth (); | 1838 int speccount = specpdl_depth (); |
1995 DEFUN ("make-directory-internal", Fmake_directory_internal, 1, 1, 0, /* | 1994 DEFUN ("make-directory-internal", Fmake_directory_internal, 1, 1, 0, /* |
1996 Create a directory. One argument, a file name string. | 1995 Create a directory. One argument, a file name string. |
1997 */ | 1996 */ |
1998 (dirname)) | 1997 (dirname)) |
1999 { | 1998 { |
2000 /* This function can call lisp */ | 1999 /* This function can GC. GC checked 1997.04.06. */ |
2001 char dir [MAXPATHLEN]; | 2000 char dir [MAXPATHLEN]; |
2002 Lisp_Object handler; | 2001 Lisp_Object handler; |
2003 struct gcpro gcpro1; | 2002 struct gcpro gcpro1; |
2004 | 2003 |
2005 CHECK_STRING (dirname); | 2004 CHECK_STRING (dirname); |
2039 DEFUN ("delete-directory", Fdelete_directory, 1, 1, "FDelete directory: ", /* | 2038 DEFUN ("delete-directory", Fdelete_directory, 1, 1, "FDelete directory: ", /* |
2040 Delete a directory. One argument, a file name or directory name string. | 2039 Delete a directory. One argument, a file name or directory name string. |
2041 */ | 2040 */ |
2042 (dirname)) | 2041 (dirname)) |
2043 { | 2042 { |
2044 /* This function can call lisp */ | 2043 /* This function can GC. GC checked 1997.04.06. */ |
2045 Lisp_Object handler; | 2044 Lisp_Object handler; |
2046 struct gcpro gcpro1; | 2045 struct gcpro gcpro1; |
2047 | 2046 |
2048 CHECK_STRING (dirname); | 2047 CHECK_STRING (dirname); |
2049 | 2048 |
2066 Delete specified file. One argument, a file name string. | 2065 Delete specified file. One argument, a file name string. |
2067 If file has multiple names, it continues to exist with the other names. | 2066 If file has multiple names, it continues to exist with the other names. |
2068 */ | 2067 */ |
2069 (filename)) | 2068 (filename)) |
2070 { | 2069 { |
2071 /* This function can call lisp */ | 2070 /* This function can GC. GC checked 1997.04.06. */ |
2072 Lisp_Object handler; | 2071 Lisp_Object handler; |
2073 struct gcpro gcpro1; | 2072 struct gcpro gcpro1; |
2074 | 2073 |
2075 CHECK_STRING (filename); | 2074 CHECK_STRING (filename); |
2076 filename = Fexpand_file_name (filename, Qnil); | 2075 filename = Fexpand_file_name (filename, Qnil); |
2095 /* Delete file FILENAME, returning 1 if successful and 0 if failed. */ | 2094 /* Delete file FILENAME, returning 1 if successful and 0 if failed. */ |
2096 | 2095 |
2097 int | 2096 int |
2098 internal_delete_file (Lisp_Object filename) | 2097 internal_delete_file (Lisp_Object filename) |
2099 { | 2098 { |
2100 /* This function can call lisp */ | 2099 /* This function can GC. GC checked 1997.04.06. */ |
2101 return NILP (condition_case_1 (Qt, Fdelete_file, filename, | 2100 return NILP (condition_case_1 (Qt, Fdelete_file, filename, |
2102 internal_delete_file_1, Qnil)); | 2101 internal_delete_file_1, Qnil)); |
2103 } | 2102 } |
2104 | 2103 |
2105 DEFUN ("rename-file", Frename_file, 2, 3, | 2104 DEFUN ("rename-file", Frename_file, 2, 3, |
2111 A number as third arg means request confirmation if NEWNAME already exists. | 2110 A number as third arg means request confirmation if NEWNAME already exists. |
2112 This is what happens in interactive use with M-x. | 2111 This is what happens in interactive use with M-x. |
2113 */ | 2112 */ |
2114 (filename, newname, ok_if_already_exists)) | 2113 (filename, newname, ok_if_already_exists)) |
2115 { | 2114 { |
2116 /* This function can call lisp */ | 2115 /* This function can GC. GC checked 1997.04.06. */ |
2117 Lisp_Object handler; | 2116 Lisp_Object handler; |
2118 struct gcpro gcpro1, gcpro2; | 2117 struct gcpro gcpro1, gcpro2; |
2119 | 2118 |
2120 GCPRO2 (filename, newname); | 2119 GCPRO2 (filename, newname); |
2121 CHECK_STRING (filename); | 2120 CHECK_STRING (filename); |
2204 A number as third arg means request confirmation if NEWNAME already exists. | 2203 A number as third arg means request confirmation if NEWNAME already exists. |
2205 This is what happens in interactive use with M-x. | 2204 This is what happens in interactive use with M-x. |
2206 */ | 2205 */ |
2207 (filename, newname, ok_if_already_exists)) | 2206 (filename, newname, ok_if_already_exists)) |
2208 { | 2207 { |
2209 /* This function can call lisp */ | 2208 /* This function can GC. GC checked 1997.04.06. */ |
2210 Lisp_Object handler; | 2209 Lisp_Object handler; |
2211 struct gcpro gcpro1, gcpro2; | 2210 struct gcpro gcpro1, gcpro2; |
2212 | 2211 |
2213 GCPRO2 (filename, newname); | 2212 GCPRO2 (filename, newname); |
2214 CHECK_STRING (filename); | 2213 CHECK_STRING (filename); |
2261 A number as third arg means request confirmation if LINKNAME already exists. | 2260 A number as third arg means request confirmation if LINKNAME already exists. |
2262 This happens for interactive use with M-x. | 2261 This happens for interactive use with M-x. |
2263 */ | 2262 */ |
2264 (filename, linkname, ok_if_already_exists)) | 2263 (filename, linkname, ok_if_already_exists)) |
2265 { | 2264 { |
2266 /* This function can call lisp */ | 2265 /* This function can GC. GC checked 1997.06.04. */ |
2267 Lisp_Object handler; | 2266 Lisp_Object handler; |
2268 struct gcpro gcpro1, gcpro2; | 2267 struct gcpro gcpro1, gcpro2; |
2269 | 2268 |
2270 GCPRO2 (filename, linkname); | 2269 GCPRO2 (filename, linkname); |
2271 CHECK_STRING (filename); | 2270 CHECK_STRING (filename); |