implement most of FileUtil