 (defn rmdir 
   "Removes a directory"
   [key-name]
-  (let [path (resolve-path [key-name])
+  (let [path (resolve-single-path [key-name])
         v (get-in @FS_ROOT path)]
     (cond 
       (nil? v) 

(defn cd 
  "Changes working directory to new path. Can use :.. as relative location, one up in path."
  [key-path]
  (let [new-path (resolve-path key-path)]
    (when-not (keypath-exists? @FS_ROOT new-path) 
      (throw (Exception. (str "Error: Keypath not found: " new-path))))
    (when-not (map? (get-in @FS_ROOT new-path)) 

        (if (empty? ks)
          nil
          (PathList. (map #(conj base-path %) ks)))) 
      (PathList. [(get-absolute-path p)]))))

(defn- resolve-single-path
  [parts]
  (let [paths (resolve-path parts)
        c (count (.paths paths))
        p (first (.paths paths))]
    (if (not= 1 c)
      (throw (Exception. (str "Error: Multiple paths found"))))
      p))

(defn ls 
  "List keys in current directory of filesystem, or given path."
  [& key-path]
  (let [p (resolve-path key-path)
        paths (.paths p)
        values 
        (if (= 1 (count paths)) 
          (map #(conj (first paths) %) 
               (sort (keys (get-in @FS_ROOT (first paths)))))
          (sort paths))]
    (->>
      values
      (map 
        #(let [v (get-in @FS_ROOT %)
               k (last %)] 
           (if (is-dir? v)
             (str "D " k) 
             (str "- " k))))
      (str/join "\n"))))

(defn pwd 
  "Print current working directory."
