convert file functions to C++ and start on add function