- /* Lisp functions for making directory listings.
+/* Lisp functions for making directory listings.
Copyright (C) 1985, 1986, 1992, 1993, 1994 Free Software Foundation, Inc.
This file is part of SXEmacs
static char *
dired_realpath(const char *file)
{
- char *result = xmalloc_atomic(4096);
-
- realpath(file, result);
+ char *result = xmalloc_atomic(4096);
+ if ( realpath(file, result) == NULL ) {
+ xfree(result);
+ result = NULL;
+ }
return result;
}
#endif
* store it to our companion bloom filter
*/
canon_name = CANONICALISE_FILENAME(statnam);
-
- /* now, recycle full name */
- fullname = make_ext_string(
- canon_name, strlen(canon_name), Qfile_name);
+ if (canon_name) {
+ /* now, recycle full name */
+ fullname = make_ext_string(
+ canon_name, strlen(canon_name), Qfile_name);
+ }
fullname = fname_as_directory(fullname);
/* now stat statnam */
*/
canon_name = CANONICALISE_FILENAME(statnam);
- /* now, recycle full name */
- fullname = make_ext_string(
- canon_name, strlen(canon_name),
- Qfile_name);
+ if (canon_name) {
+ /* now, recycle full name */
+ fullname = make_ext_string(
+ canon_name, strlen(canon_name),
+ Qfile_name);
+ }
fullname = fname_as_directory(fullname);
/* now stat statnam */
- With the former variant it is NOT possible to have
the trivial filenames on the result list, since a
match against "^[.]$" would exclude everything, while
- actually it was likely meant to _solely_ exclude "."
+ actually it was likely meant to _solely_ exclude "."
from the result list
- Furthermore, we _MUST_ traverse in preorder,
otherwise there is the possibility that pathnames are
}
#if USE_MATCH_ARG
- if (!NILP(match) && !pathname_matches_p(name, match, bufp)) {
+ if (!NILP(match) && bufp && !pathname_matches_p(name, match, bufp)) {
result_p = 0;
}
#endif
} else if (EQ(result_type, Qdesc_sorted_list)) {
final_result = Fdllist_to_list(result);
final_result = Fsort(final_result, Qstring_greaterp);
- } else if (EQ(result_type, Qt) || EQ(result_type, Qlist)) {
+ } else if (!NILP(result_type) || EQ(result_type, Qlist)) {
final_result = Fdllist_to_list(result);
}
The two latter types can be useful if you plan to sort the result
yourself, or want to feed the result to further processing.
+For compatibility with XEmacs' NOSORT argument to this function,
+RESULT-TYPE can also be any non-nil value. In that case it will
+return an unsorted list. (http://issues.sxemacs.org/show_bug.cgi?id=163)
+
Optional argument FILES-ONLY can be one of:
- t to return only files and symlinks in DIRECTORY
- nil (default) to return all entries (files, symlinks, and
maximal recursion depth, use 0 to emulate old `directory-files'.
Optional argument SYMLINK-IS-FILE specifies whether symlinks
-should be resolved \(which is the default behaviour\) or whether
+should be resolved \(which is the default behaviour\) or whether
they are treated as ordinary files \(non-nil\), in the latter
case symlinks to directories are not recurred.
==
XSTRING_CHAR_LENGTH(bestmatch)))
/* If there is more than one exact match aside from
- case, and one of them is exact including case,
- prefer that one. */
+ case, and one of them is exact including case,
+ prefer that one. */
&& 0 > scmp_1(p2,
XSTRING_DATA(file),
file_name_length, 0)