X-Git-Url: http://cgit.sxemacs.org/?p=sxemacs;a=blobdiff_plain;f=src%2Ffileio.c;h=365885f9960a05b4e4d8f8735f703df947817897;hp=bae112afc0c2f01ae3d31c242da97f04132be449;hb=fbcdf082dfcbcfcf368088b4e5e990488cffc940;hpb=2bd6f85ce9abc38a1033881e210f87eae32dfdf2 diff --git a/src/fileio.c b/src/fileio.c index bae112a..365885f 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -35,6 +35,7 @@ along with this program. If not, see . */ #ifdef FILE_CODING #include "mule/file-coding.h" #endif +#include "ent/ent.h" #ifdef HAVE_LIBGEN_H /* Must come before sysfile.h */ #include @@ -377,6 +378,22 @@ Return the directory component in file name FILENAME. Return nil if FILENAME does not include a directory. Otherwise return a directory spec. Given a Unix syntax file name, returns a string ending in slash. + +Concatenating the return of file-name-directory and the string +returned by file-name-nondirectory yields a complete pathname. + +Samples: +filename file-name-directory file-name-nondirectory +"/usr/lib" "/usr/" "lib" +"/usr/lib/" "/usr/lib/" "" +"/usr/" "/usr/" "" +"/usr" "/" "usr" +"usr" nil "usr" +"/" "/" "" +"." nil "." +"./" "./" "" +".." nil ".." + */ (filename)) { @@ -414,6 +431,24 @@ Return file name FILENAME sans its directory. For example, in a Unix-syntax file name, this is everything after the last slash, or the entire name if it contains no slash. + +Concatenating the return of file-name-directory and the string +returned by file-name-nondirectory yields a complete pathname. + +It is equivalent to the GNU version of basename. + +Samples: +filename file-name-directory file-name-nondirectory +"/usr/lib" "/usr/" "lib" +"/usr/lib/" "/usr/lib/" "" +"/usr/" "/usr/" "" +"/usr" "/" "usr" +"usr" nil "usr" +"/" "/" "" +"." nil "." +"./" "./" "" +".." nil ".." + */ (filename)) { @@ -1034,7 +1069,7 @@ See also the function `substitute-in-file-name'. file_name_as_directory((char *)target, (char *)newdir, tlen); } - xstrncat((char *)target, (char *)nm, tlen); + xstrncat((char *)target, (char *)nm, tlen-1); /* ASSERT (IS_DIRECTORY_SEP (target[0])) if not VMS */ @@ -1544,7 +1579,7 @@ A prefix arg makes KEEP-TIME non-nil. O_RDONLY | OPEN_BINARY, 0); if (ifd < 0) { report_file_error("Opening input file", list1(filename)); - return; + goto end; } record_unwind_protect(close_file_unwind, make_int(ifd)); @@ -1617,6 +1652,7 @@ A prefix arg makes KEEP-TIME non-nil. unbind_to(speccount, Qnil); } +end: UNGCPRO; return Qnil; }