7 inline string copyFile(const string &filename, const string &ext)
9 string newname = string(tempnam(NULL, NULL)) + ext;
10 string oldname = string("data/") + filename + ext;
13 int inf = open(oldname.c_str(), O_RDONLY);
14 int outf = open(newname.c_str(), O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR);
15 while((bytes = read(inf, buffer, sizeof(buffer))) > 0)
16 write(outf, buffer, bytes);
22 inline void deleteFile(const string &filename)
24 remove(filename.c_str());