 class BabyFtpd.FileSystem
   constructor: ()->
     @baseDir = null
+    @quotaSize = 0
   
   setBase: (dirPath)->
     @baseDir = dirPath
+  
+  setQuotaSize: (qSize)->
+    @quotaSize = qSize
   
   getNewPath: (nowDir, reqPath)->
     if reqPath.indexOf("/") is 0

        @dtpServer.store (storeData)=>
          @fileSystem.setFile storeData, @sessionDir, reqPath, (err)=>
            if err?
              @reply 550
            else
              @reply 250
      catch err

      throw new Error "no directory"
  
  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
  
  getFile: (nowDir, reqPath, callback)->
    retPath = @getNewPath nowDir, reqPath
    fs.readFile @baseDir+retPath, callback
  
  setFile: (storeData, nowDir, reqPath, callback)->
    if @quotaSize > 0 and storeData.length > @quotaSize
      # 簡易"Disk quota exceeded"エラーシミュレーター
      winston.log "info", "Disk quota exceeded"
      callback(new Error("Disk quota exceeded"))
    else
      srorePath = @getNewPath  nowDir, reqPath
      winston.log "info", "save #{srorePath}"
      fs.writeFile @baseDir+srorePath, storeData, "binary", callback
  
  removeFile: (reqPath, callback)->
    fs.unlink @baseDir+reqPath, callback
