Skip to content

Instantly share code, notes, and snippets.

@saschagehlich
Created August 26, 2010 01:28
Show Gist options
  • Save saschagehlich/550617 to your computer and use it in GitHub Desktop.
Save saschagehlich/550617 to your computer and use it in GitHub Desktop.
getSize = (filename, callback) ->
fs.stat filename, (err, stat) ->
if err
if err.errno == process.ENOENT
return callback null, 0
return callback err
callback null, stat.size
getTotal = (filename, num, callback) ->
finish = ->
callback total
for i in [0...num]
Common.getSize "#{filename}.#{i}", (err, size) ->
throw err if err
total += size
finish() if i is num - 1
getTotal filename, 3, (total) ->
console.log total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment