Copied file manipulation methods from old version.

Will be refined soon.