fs = require 'fs'
IOUtil = (require '../../src/util/IOUtil.coffee').IOUtil
utils = (require '../TestUtils.coffee')

exports.testMakeSizeAndRm = (test) ->
  test.expect 5
  dir = '/tmp/test1/test11/test111'
  IOUtil.makeDirectory$String dir
  for i in [0..9]
    buf = new Buffer 100
    fd = fs.openSync dir + '/' + i.toString(), "w+"
    fs.writeSync fd, buf, 0, buf.length
  size = IOUtil.getDirectorySize$String dir
  test.equal size, 1000
  size = IOUtil.getDirectorySize$String '/tmp/test1/test11'
  test.equal size, 1000
  size = IOUtil.getDirectorySize$String '/tmp/test1'
  test.equal size, 1000
  IOUtil.removeDirectory$String dir
  files = fs.readdirSync '/tmp/test1/test11'
  test.equal files.length, 0
  size = IOUtil.getDirectorySize$String '/tmp/test1'
  test.equal size, 0
  IOUtil.removeDirectory$String '/tmp/test1'
  test.done()