# HG changeset patch # User mas01cr # Date 1187715920 0 # Node ID 9503faa2981c4a2f6b1f8d1d9df91ae304b6ad60 # Parent 657e638b87efab27784deb683f80dfea54bb77f2 Don't truncate on creation: instead error if the requested database file already exists diff -r 657e638b87ef -r 9503faa2981c audioDB.cpp --- a/audioDB.cpp Tue Aug 21 16:59:33 2007 +0000 +++ b/audioDB.cpp Tue Aug 21 17:05:20 2007 +0000 @@ -97,9 +97,9 @@ #define O2_DEBUG - void audioDB::error(const char* a, const char* b){ - cerr << a << ":" << b << endl; - exit(1); +void audioDB::error(const char* a, const char* b) { + cerr << a << ": " << b << endl; + exit(1); } audioDB::audioDB(const unsigned argc, char* const argv[], adb__queryResult *adbQueryResult): @@ -467,8 +467,8 @@ } void audioDB::create(const char* dbName){ - if ((dbfid = open (dbName, O_RDWR|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) < 0) - error("Can't open database file", dbName); + if ((dbfid = open (dbName, O_RDWR|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) < 0) + error("Can't create database file", dbName); get_lock(dbfid, 1); // go to the location corresponding to the last byte