Convert cmdfiles.c to C++