示例#1
0
文件: filelib.c 项目: cs50/spl
Iterator newDirectoryIterator(string dir) {
   Iterator iterator;
   string *names;
   int i;

   iterator = newListIterator(sizeof (string), NULL);
   names = listDirectory(dir);
   for (i = 0; names[i] != NULL; i++) {
      addToIteratorList(iterator, &names[i]);
   }
   return iterator;
}
示例#2
0
文件: filelib.c 项目: cs50/spl
static void mapDirectoryTree(string dir, Iterator iterator) {
   string *names, pathname;
   int i;

   names = listDirectory(dir);
   for (i = 0; names[i] != NULL; i++) {
      if (dir == NULL) {
         pathname = names[i];
      } else {
         pathname = dir;
         if (!endsWith(pathname, "/")) {
            pathname = concat(pathname, "/");
         }
         pathname = concat(pathname, names[i]);
      }
      if (isDirectory(pathname)) {
         mapDirectoryTree(pathname, iterator);
      } else {
         addToIteratorList(iterator, &pathname);
      }
   }
}
示例#3
0
static void addKeyToIterator(BSTNode node, void *data) {
   string key;

   key = (string) getKey(node).pointerRep;
   addToIteratorList((Iterator) data, &key);
}