 #
 # # Baby FTP Deamon
 #
-net  = require "net"
-fs   = require "fs"
-exec = require("child_process").exec
+net       = require "net"
+fs        = require "fs"
+exec      = require("child_process").exec
 
 module.exports = class BabyFtpd
   @sysName: "Node_BabyFTP_Server"

    "PWD": ()->
      @reply 257, "\"#{@sessionDir}\""
    
    "NLST": ()->
      fs.readdir @fileSystem.baseDir+@sessionDir, (err, files)=>
        @dtpServer.dataQueue = files.join("\r\n") + "\r\n"
        @reply 150
    
    "LIST": ()->
      exec "export LANG=en_US.UTF-8; ls -l #{@fileSystem.baseDir}#{@sessionDir}", (err, stdout, stderr)=>
        stdout = stdout.replace(/^total [0-9]+$/im, "").trim()
        @dtpServer.dataQueue = stdout
        @reply 150
    
    "RETR": ()->
      @dtpServer.dataQueue = "<html></html>"

      retPath = tmpDir.join("/")
    fs.readdirSync @baseDir+retPath
    retPath
  
  getNlst: (nowDir, reqPath, callback)->
    retPath = @getNewPath nowDir, reqPath
    fs.readdir @baseDir+retPath, callback
  
  getList: (nowDir, reqPath, callback)->
    retPath = @getNewPath nowDir, reqPath
    exec "export LANG=en_US.UTF-8; ls -l #{@baseDir}#{retPath}", callback
