Mercurial > emacs
comparison src/fileio.c @ 3705:309c27256ceb
(Fcopy_file): Pass all the args to the handler.
(Fwrite_region): Use call6.
(Frename_file): Look for handler for newname.
(Fadd_name_to_file): Pass arg ok_if_already_exists to handler.
(Fmake_symbolic_link): Likewise.
(Ffile_newer_than_file_p): Check both file names for handler.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 13 Jun 1993 00:07:35 +0000 |
parents | 3c4b5489d2b4 |
children | 4550c56785d8 |
comparison
equal
deleted
inserted
replaced
3704:8488ad8eb302 | 3705:309c27256ceb |
---|---|
1582 char buf[16 * 1024]; | 1582 char buf[16 * 1024]; |
1583 struct stat st; | 1583 struct stat st; |
1584 Lisp_Object handler; | 1584 Lisp_Object handler; |
1585 struct gcpro gcpro1, gcpro2; | 1585 struct gcpro gcpro1, gcpro2; |
1586 int count = specpdl_ptr - specpdl; | 1586 int count = specpdl_ptr - specpdl; |
1587 Lisp_Object args[6]; | |
1587 | 1588 |
1588 GCPRO2 (filename, newname); | 1589 GCPRO2 (filename, newname); |
1589 CHECK_STRING (filename, 0); | 1590 CHECK_STRING (filename, 0); |
1590 CHECK_STRING (newname, 1); | 1591 CHECK_STRING (newname, 1); |
1591 filename = Fexpand_file_name (filename, Qnil); | 1592 filename = Fexpand_file_name (filename, Qnil); |
1592 newname = Fexpand_file_name (newname, Qnil); | 1593 newname = Fexpand_file_name (newname, Qnil); |
1593 | 1594 |
1594 /* If the input file name has special constructs in it, | 1595 /* If the input file name has special constructs in it, |
1595 call the corresponding file handler. */ | 1596 call the corresponding file handler. */ |
1596 handler = Ffind_file_name_handler (filename); | 1597 handler = Ffind_file_name_handler (filename); |
1598 /* Likewise for output file name. */ | |
1599 if (NILP (handler)) | |
1600 handler = Ffind_file_name_handler (newname); | |
1597 if (!NILP (handler)) | 1601 if (!NILP (handler)) |
1598 return call3 (handler, Qcopy_file, filename, newname); | 1602 return call5 (handler, Qcopy_file, filename, newname, |
1599 /* Likewise for output file name. */ | 1603 ok_if_already_exists, keep_date); |
1600 handler = Ffind_file_name_handler (newname); | |
1601 if (!NILP (handler)) | |
1602 return call3 (handler, Qcopy_file, filename, newname); | |
1603 | 1604 |
1604 if (NILP (ok_if_already_exists) | 1605 if (NILP (ok_if_already_exists) |
1605 || XTYPE (ok_if_already_exists) == Lisp_Int) | 1606 || XTYPE (ok_if_already_exists) == Lisp_Int) |
1606 barf_or_query_if_file_exists (newname, "copy to it", | 1607 barf_or_query_if_file_exists (newname, "copy to it", |
1607 XTYPE (ok_if_already_exists) == Lisp_Int); | 1608 XTYPE (ok_if_already_exists) == Lisp_Int); |
1745 newname = Fexpand_file_name (newname, Qnil); | 1746 newname = Fexpand_file_name (newname, Qnil); |
1746 | 1747 |
1747 /* If the file name has special constructs in it, | 1748 /* If the file name has special constructs in it, |
1748 call the corresponding file handler. */ | 1749 call the corresponding file handler. */ |
1749 handler = Ffind_file_name_handler (filename); | 1750 handler = Ffind_file_name_handler (filename); |
1751 if (NILP (handler)) | |
1752 handler = Ffind_file_name_handler (newname); | |
1750 if (!NILP (handler)) | 1753 if (!NILP (handler)) |
1751 return call4 (handler, Qrename_file, | 1754 return call4 (handler, Qrename_file, |
1752 filename, newname, ok_if_already_exists); | 1755 filename, newname, ok_if_already_exists); |
1753 | 1756 |
1754 if (NILP (ok_if_already_exists) | 1757 if (NILP (ok_if_already_exists) |
1806 | 1809 |
1807 /* If the file name has special constructs in it, | 1810 /* If the file name has special constructs in it, |
1808 call the corresponding file handler. */ | 1811 call the corresponding file handler. */ |
1809 handler = Ffind_file_name_handler (filename); | 1812 handler = Ffind_file_name_handler (filename); |
1810 if (!NILP (handler)) | 1813 if (!NILP (handler)) |
1811 return call3 (handler, Qadd_name_to_file, filename, newname); | 1814 return call4 (handler, Qadd_name_to_file, filename, newname, |
1815 ok_if_already_exists); | |
1812 | 1816 |
1813 if (NILP (ok_if_already_exists) | 1817 if (NILP (ok_if_already_exists) |
1814 || XTYPE (ok_if_already_exists) == Lisp_Int) | 1818 || XTYPE (ok_if_already_exists) == Lisp_Int) |
1815 barf_or_query_if_file_exists (newname, "make it a new name", | 1819 barf_or_query_if_file_exists (newname, "make it a new name", |
1816 XTYPE (ok_if_already_exists) == Lisp_Int); | 1820 XTYPE (ok_if_already_exists) == Lisp_Int); |
1857 | 1861 |
1858 /* If the file name has special constructs in it, | 1862 /* If the file name has special constructs in it, |
1859 call the corresponding file handler. */ | 1863 call the corresponding file handler. */ |
1860 handler = Ffind_file_name_handler (filename); | 1864 handler = Ffind_file_name_handler (filename); |
1861 if (!NILP (handler)) | 1865 if (!NILP (handler)) |
1862 return call3 (handler, Qmake_symbolic_link, filename, linkname); | 1866 return call4 (handler, Qmake_symbolic_link, filename, linkname, |
1867 ok_if_already_exists); | |
1863 | 1868 |
1864 if (NILP (ok_if_already_exists) | 1869 if (NILP (ok_if_already_exists) |
1865 || XTYPE (ok_if_already_exists) == Lisp_Int) | 1870 || XTYPE (ok_if_already_exists) == Lisp_Int) |
1866 barf_or_query_if_file_exists (linkname, "make it a link", | 1871 barf_or_query_if_file_exists (linkname, "make it a link", |
1867 XTYPE (ok_if_already_exists) == Lisp_Int); | 1872 XTYPE (ok_if_already_exists) == Lisp_Int); |
2315 UNGCPRO; | 2320 UNGCPRO; |
2316 | 2321 |
2317 /* If the file name has special constructs in it, | 2322 /* If the file name has special constructs in it, |
2318 call the corresponding file handler. */ | 2323 call the corresponding file handler. */ |
2319 handler = Ffind_file_name_handler (abspath1); | 2324 handler = Ffind_file_name_handler (abspath1); |
2325 if (NILP (handler)) | |
2326 handler = Ffind_file_name_handler (abspath2); | |
2320 if (!NILP (handler)) | 2327 if (!NILP (handler)) |
2321 return call3 (handler, Qfile_newer_than_file_p, abspath1, abspath2); | 2328 return call3 (handler, Qfile_newer_than_file_p, abspath1, abspath2); |
2322 | 2329 |
2323 if (stat (XSTRING (abspath1)->data, &st) < 0) | 2330 if (stat (XSTRING (abspath1)->data, &st) < 0) |
2324 return Qnil; | 2331 return Qnil; |
2552 call the corresponding file handler. */ | 2559 call the corresponding file handler. */ |
2553 handler = Ffind_file_name_handler (filename); | 2560 handler = Ffind_file_name_handler (filename); |
2554 | 2561 |
2555 if (!NILP (handler)) | 2562 if (!NILP (handler)) |
2556 { | 2563 { |
2557 Lisp_Object args[7]; | |
2558 Lisp_Object val; | 2564 Lisp_Object val; |
2559 args[0] = handler; | 2565 val = call6 (handler, Qwrite_region, start, end, |
2560 args[1] = Qwrite_region; | 2566 filename, append, visit); |
2561 args[2] = start; | |
2562 args[3] = end; | |
2563 args[4] = filename; | |
2564 args[5] = append; | |
2565 args[6] = visit; | |
2566 val = Ffuncall (7, args); | |
2567 | 2567 |
2568 /* Do this before reporting IO error | 2568 /* Do this before reporting IO error |
2569 to avoid a "file has changed on disk" warning on | 2569 to avoid a "file has changed on disk" warning on |
2570 next attempt to save. */ | 2570 next attempt to save. */ |
2571 if (EQ (visit, Qt) || XTYPE (visit) == Lisp_String) | 2571 if (EQ (visit, Qt) || XTYPE (visit) == Lisp_String) |