summary refs log tree commit diff
path: root/src/rt/rust_builtin.cpp
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2011-06-10 12:56:42 -0700
committerGraydon Hoare <graydon@mozilla.com>2011-06-10 12:57:29 -0700
commit52c4c9014f62ddf799b316cca59dd0f4070b9c06 (patch)
treec755438a0bbacaef8e2282f055c9d5ab51b14854 /src/rt/rust_builtin.cpp
parent4634f236a94fdbe5640b2ffeffc91d8016132264 (diff)
downloadrust-52c4c9014f62ddf799b316cca59dd0f4070b9c06.tar.gz
rust-52c4c9014f62ddf799b316cca59dd0f4070b9c06.zip
Encode meta tags in the crate and start sketching enhanced logic for resolving crate "use" directives.
Now with extra "works on OSX" kludging.
Diffstat (limited to 'src/rt/rust_builtin.cpp')
-rw-r--r--src/rt/rust_builtin.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index bc2c5adde60..f4b2639b137 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -486,8 +486,8 @@ rust_str* c_str_to_rust(rust_task *task, char const *str) {
 
 extern "C" CDECL rust_vec*
 rust_list_files(rust_task *task, rust_str *path) {
-#if defined(__WIN32__)
     array_list<rust_str*> strings;
+#if defined(__WIN32__)
     WIN32_FIND_DATA FindFileData;
     HANDLE hFind = FindFirstFile((char*)path->data, &FindFileData);
     if (hFind != INVALID_HANDLE_VALUE) {
@@ -496,11 +496,17 @@ rust_list_files(rust_task *task, rust_str *path) {
         } while (FindNextFile(hFind, &FindFileData));
         FindClose(hFind);
     }
-    return vec_alloc_with_data(task, strings.size(), strings.size(),
-                               sizeof(rust_str*), strings.data());
 #else
-    return NULL;
+  DIR *dirp = opendir((char*)path->data);
+  if (dirp) {
+      struct dirent *dp;
+      while ((dp = readdir(dirp)))
+          strings.push(c_str_to_rust(task, dp->d_name));
+      closedir(dirp);
+  }
 #endif
+  return vec_alloc_with_data(task, strings.size(), strings.size(),
+                             sizeof(rust_str*), strings.data());
 }
 
 #if defined(__WIN32__)
@@ -562,6 +568,6 @@ get_time(rust_task *task, uint32_t *sec, uint32_t *usec) {
 // indent-tabs-mode: nil
 // c-basic-offset: 4
 // buffer-file-coding-system: utf-8-unix
-// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
+// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
 // End:
 //