var path      = require('path')
var assert    = require('assert')
var stat      = require('./stat')
var exists    = require('./exists')
// var revFile   = require('./revFile')
var readFile  = require('./readFile')
var writeFile = require('./writeFile')
var name      = require('../path/name')
var segments  = require('../path/segments')
var eachAsync = require('../async/iterate').map
var rename    = require('../string/placeholders')

// THIS NEEDS WORK!!
// options: flatten, preserve [dir structure], noclobber.
function copy (files, dest, opts, cb) {
  var defaults = {flatten: false, noclobber: false}

  if (typeof opts === 'function') {
    cb = opts
    opts = defaults
  } else {
    opts = opts || defaults
  }

  files = Array.isArray(files) ? files : [files]

  eachAsync(files, function (file, key, done) {
    readFile(file, function (err, data) {
      assert.ifError(err)

      var method
      var filepath
      var destination

      if (opts.flatten) method = 'last'
      else method = 'fromFirst'

      filepath = segments[method](file)
      destination = path.resolve(dest, filepath)

      if (opts.noclobber && exists(destination)) {
        if (stat(destination).content === stat(file).content) {
          return done(null, file)
        } else {
          // destination = revFile(destination)
          var fn = rename()(':dest/:file:bkup:ext')
          destination = fn({
            dest: name.dir(destination),
            file: name.file(destination),
            ext: name.ext(destination),
            bkup: 'hello'//something goes here
          })
        }
      }

      writeFile(destination, data, function (err) {
        assert.ifError(err)
        done(null, file)
      })
    })
  }, function (err, res) {
    assert.ifError(err)
    cb(res)
  })
}

function copySync (files, dest) {
  files = Array.isArray(files) ? files : [files]

  files.forEach(function (file) {
    var destFile = path.resolve(dest, segments.fromFirst(file))
    var content = readFile(file)
    writeFile(destFile, content)
  })
}

module.exports = copy
module.exports.sync = copySync

@@ -133,48 +133,8 @@
 s')%0A
-// var revFile   = require('./revFile')%0A
 var 
@@ -338,16 +338,61 @@
 e').map%0A
+var randHex   = require('../random/randHex')%0A
 var rena
@@ -442,16 +442,22 @@
 // THIS 
+STILL 
 NEEDS WO
@@ -474,55 +474,94 @@
 tion
-s: flatten,
+al rename function or
  p
+a
 re
-serve %5Bdir structure%5D, noclobber
+nt path segment instead of randHex.%0A// better error handling
 .%0Afu
@@ -1324,56 +1324,8 @@
 e %7B%0A
-          // destination = revFile(destination)%0A
     
@@ -1361,20 +1361,20 @@
 t/:file:
-bkup
+vers
 :ext')%0A 
@@ -1417,16 +1417,17 @@
     dest
+ 
 : name.d
@@ -1459,16 +1459,17 @@
     file
+ 
 : name.f
@@ -1501,16 +1501,18 @@
      ext
+  
 : name.e
@@ -1544,42 +1544,31 @@
     
-bkup: 'hello'//something goes here
+vers : '-' + randHex(4)
 %0A   

update file/copy.js