13
0
livetrax/libs/taglib/tests/utils.h
Paul Davis 1c299d5a5c merge Sakari's (sbergen) branch back into 3.0, removing libsndfile and adding taglib
git-svn-id: svn://localhost/ardour2/branches/3.0@3736 d708f5d6-7413-0410-9779-e7cbd77b26cf
2008-09-17 08:44:51 +00:00

26 lines
637 B
C++

#include <string>
#include <stdio.h>
#include <sys/fcntl.h>
using namespace std;
inline string copyFile(const string &filename, const string &ext)
{
string newname = string(tempnam(NULL, NULL)) + ext;
string oldname = string("data/") + filename + ext;
char buffer[4096];
int bytes;
int inf = open(oldname.c_str(), O_RDONLY);
int outf = open(newname.c_str(), O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR);
while((bytes = read(inf, buffer, sizeof(buffer))) > 0)
write(outf, buffer, bytes);
close(outf);
close(inf);
return newname;
}
inline void deleteFile(const string &filename)
{
remove(filename.c_str());
}