   var entry = readdir(dp)
   while entry != nil {
     count += 1
-    if entry.memory.d_type == 4 {
-      var dirName = entry.memory.d_name
+    if entry!.pointee.d_type == 4 {
+      var dirName = entry!.pointee.d_name
       withUnsafePointer(&dirName) { ptr in
-        if let name = String.fromCString(UnsafePointer<CChar>(ptr)) {
-          if name != "." && name != ".." {
-            spelunkDir("\(path)\(name)/")
-          }
+        let name = String(cString: UnsafePointer<CChar>(ptr))
+        if name != "." && name != ".." {
+          spelunkDir(path: "\(path)\(name)/")
         }
       }
     }

}

func browseDir(pathBytes: [UInt8]) throws {
  let fb = try FileBrowser(pathBytes: pathBytes)
  while fb.next() {
    count += 1
    if fb.type == .D {
      let nameBytes = fb.nameBytes
      let len = nameBytes.count
      if len <= 2 && nameBytes[0] == 46 && (len == 1 || nameBytes[1] == 46) {
        // Ignore Dot file: . ..
      } else {
        var cp = [UInt8]()
        cp.reserveCapacity(pathBytes.count + nameBytes.count + 1)
        cp += pathBytes
        cp.removeLast() // Remove null-byte 0
        cp += nameBytes
        cp.append(47)
        cp.append(0) // Now append the trailing null-byte 0
        try browseDir(cp)
      }
    }
  }
}

func browseDir2(pathBytes: [UInt8]) throws {
  let fb = try FileBrowser(pathBytes: pathBytes)
  while fb.next() {
    count += 1
    if fb.type == .D {
      var rn = fb.rawEntry.memory.d_name
      try withUnsafePointer(&rn) { ptr in
        let len = Int(Sys.strlen(UnsafePointer<CChar>(ptr)))
        let b = UnsafeBufferPointer<UInt8>(start: UnsafePointer<UInt8>(ptr),
            count: len)
        if len <= 2 && b[0] == 46 && (len == 1 || b[1] == 46) {
          // Ignore Dot file: . ..
        } else {
          var cp = [UInt8]()
          cp.reserveCapacity(pathBytes.count + len + 1)
          cp += pathBytes
          cp.removeLast() // Remove null-byte 0
          cp += b
          cp.append(47)
          cp.append(0) // Now append the trailing null-byte 0
          try browseDir2(cp)
        }
      }
    }
  }
}

func peekDir(pathBytes: [UInt8]) {
  var pb = pathBytes
  var store = [([UInt8], COpaquePointer)]()
  store.reserveCapacity(128)
  PATH: while store.count >= 0 { // Trick the compiler.
    let cap = UnsafePointer<CChar>(pb)

              cp += b
              cp.append(47)
              cp.append(0) // Now append the trailing null-byte 0
              store.append((pb, dp!))
              pb = cp
              ignore = false
            }
