Mercurial > hg > audiodb
changeset 31:9503faa2981c
Don't truncate on creation: instead error if the requested database file
already exists
author | mas01cr |
---|---|
date | Tue, 21 Aug 2007 17:05:20 +0000 |
parents | 657e638b87ef |
children | bc84daa6c362 |
files | audioDB.cpp |
diffstat | 1 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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