#include <rmsdef.h>
#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
/* The d_nameln member of a struct dirent includes the '\0' character
on some systems, but not on others. What's worse, you can't tell
at compile-time which one it will be, since it really depends on
Lisp_Object encoded_directory;
Lisp_Object handler;
struct re_pattern_buffer *bufp;
+ int needsep = 0;
+ struct gcpro gcpro1, gcpro2;
/* If the file name has special constructs in it,
call the corresponding file handler. */
return Ffuncall (6, args);
}
- {
- struct gcpro gcpro1, gcpro2;
-
- /* Because of file name handlers, these functions might call
+ /* Because of file name handlers, these functions might call
Ffuncall, and cause a GC. */
- GCPRO1 (match);
- directory = Fexpand_file_name (directory, Qnil);
- UNGCPRO;
- GCPRO2 (match, directory);
- dirfilename = Fdirectory_file_name (directory);
- UNGCPRO;
- }
+ GCPRO1 (match);
+ directory = Fexpand_file_name (directory, Qnil);
+ UNGCPRO;
+ GCPRO2 (match, directory);
+ dirfilename = Fdirectory_file_name (directory);
+ UNGCPRO;
if (!NILP (match))
{
report_file_error ("Opening directory", Fcons (directory, Qnil));
list = Qnil;
- dirnamelen = XSTRING (encoded_directory)->size;
+ dirnamelen = STRING_BYTES (XSTRING (encoded_directory));
re_match_object = Qt;
+ /* Decide whether we need to add a directory separator. */
+#ifndef VMS
+ if (dirnamelen == 0
+ || !IS_ANY_SEP (XSTRING (encoded_directory)->data[dirnamelen - 1]))
+ needsep = 1;
+#endif /* not VMS */
+
+ GCPRO2 (encoded_directory, list);
+
/* Loop reading blocks */
while (1)
{
{
int afterdirindex = dirnamelen;
int total = len + dirnamelen;
- int needsep = 0;
+ int nchars;
- /* Decide whether we need to add a directory separator. */
-#ifndef VMS
- if (dirnamelen == 0
- || !IS_ANY_SEP (XSTRING (encoded_directory)->data[dirnamelen - 1]))
- needsep = 1;
-#endif /* VMS */
-
- name = make_uninit_string (total + needsep);
+ name = make_uninit_multibyte_string (total + needsep,
+ total + needsep);
bcopy (XSTRING (encoded_directory)->data, XSTRING (name)->data,
dirnamelen);
if (needsep)
XSTRING (name)->data[afterdirindex++] = DIRECTORY_SEP;
bcopy (dp->d_name,
XSTRING (name)->data + afterdirindex, len);
+ nchars = chars_in_text (XSTRING (name)->data,
+ afterdirindex + len);
+ XSTRING (name)->size = nchars;
+ if (nchars == STRING_BYTES (XSTRING (name)))
+ SET_STRING_BYTES (XSTRING (name), -1);
}
else
name = make_string (dp->d_name, len);
}
}
closedir (d);
+ UNGCPRO;
if (!NILP (nosort))
return list;
return Fsort (Fnreverse (list), Qstring_lessp);
return file_name_completion (file, directory, 1, 0);
}
+static int file_name_completion_stat ();
+
Lisp_Object
file_name_completion (file, dirname, all_flag, ver_flag)
Lisp_Object file, dirname;
return Fsignal (Qquit, Qnil);
}
+static int
file_name_completion_stat (dirname, dp, st_addr)
Lisp_Object dirname;
DIRENTRY *dp;
return Flist (sizeof(values) / sizeof(values[0]), values);
}
\f
+void
syms_of_dired ()
{
Qdirectory_files = intern ("directory-files");