     @dnsPort  = options.dnsPort  ? 20560
     @timeout  = options.timeout  ? 15 * 60 * 1000
     @domain   = options.domain   ? "test"
-    @root     = options.root     ? join process.env.HOME, ".pow"
+    @root     = options.root     ? path.join process.env.HOME, ".pow"
 
   findApplicationRootForHost: (host, callback) ->
     @gatherApplicationRoots (err, roots) =>

fs     = require "fs"
{join} = require "path"
async  = require "async"

getFilenamesForHost = (host) ->
  parts = host.split "."
  length = parts.length - 2
  for i in [0..length]
    parts.slice(i, length + 1).join "."

module.exports = class Configuration
  constructor: (options = {}) ->


  gatherApplicationRoots: (callback) ->
    roots = {}
    mkdirp @root, (err) =>
      return callback err if err
      fs.readdir @root, (err, files) =>
        return callback err if err
        async.forEach files, (file, next) =>
          root = path.join @root, file
          fs.lstat root, (err, stats) ->
            return callback err if err
            if stats.isSymbolicLink()
              fs.readlink root, (err, resolvedPath) ->
                return callback err if err
                roots[file] = resolvedPath
                next()
            else if stats.isDirectory()
              roots[file] = root
              next()
            else
              next()
        , (err) ->
          callback err, roots
