Loading src/backend.h +0 −1 Original line number Diff line number Diff line Loading @@ -131,7 +131,6 @@ namespace authdb{ void write(const unsigned char *dest,size_t destsize); void read(char unsigned *src,size_t srcsize); friend class Domain; friend class RecordIndex; friend class DomainBackend; friend class Export; Loading src/backends/file.cpp +19 −1 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ #include "file.h" authdb::File::File(const char* path,size_t version,const char *domain){ authdb::File::File(const char* path,size_t version,const char *domain) : _filePath(path) { #ifdef Windows // Attempt to open the file. _FileDes = INVALID_HANDLE_VALUE; Loading Loading @@ -619,3 +619,21 @@ void authdb::File::vacuum(){ ::write(_FileDes, &head, sizeof(head)); #endif } void authdb::File::purge(){ #ifdef Windows if(_FileDes != INVALID_HANDLE_VALUE){ CloseHandle(_FileDes); _FileDes = INVALID_HANDLE_VALUE; } DeleteFileA(_filePath.c_str()); DeleteFileA(_lockFile.c_str()); #else if(_FileDes >= 0){ close(_FileDes); _FileDes = -1; } unlink(_filePath.c_str()); unlink(_lockFile.c_str()); #endif } src/backends/file.h +2 −0 Original line number Diff line number Diff line Loading @@ -63,7 +63,9 @@ namespace authdb { void newRevesion(); void vacuum(); void purge() override; private: std::string _filePath; std::string _lockFile; #ifdef Windows Loading src/domain.cpp +0 −25 Original line number Diff line number Diff line Loading @@ -90,32 +90,7 @@ void authdb::Domain::create(authdb::AuthBackend& backend,class DomainData *data) } void authdb::Domain::remove(AuthBackend& backend, const uuid::uuid &uid){ AuthBackend::Guard guard(backend); authdb::AuthData::Record cur; size_t rd=sizeof(authdb::AuthHeader),end=backend.end(); while(rd+sizeof(AuthData::Record)<=end){ backend.setPos(rd); backend.read((unsigned char*)&cur,sizeof(AuthData::Record)); size_t next=backend.getPos()+cur.datasize; if(next<backend.getPos() || next>end) break; rd=next; if( uid==cur.ruid && cur.type==DataType::DomainData && strcmp(cur.fieldname,"domainoptions")==0){ cur.data=new char[cur.datasize]; backend.read((unsigned char*)cur.data,cur.datasize); unlink(cur.data); delete[] cur.data; } } backend.delRecord(uid,DataType::DomainData); } Loading Loading
src/backend.h +0 −1 Original line number Diff line number Diff line Loading @@ -131,7 +131,6 @@ namespace authdb{ void write(const unsigned char *dest,size_t destsize); void read(char unsigned *src,size_t srcsize); friend class Domain; friend class RecordIndex; friend class DomainBackend; friend class Export; Loading
src/backends/file.cpp +19 −1 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ #include "file.h" authdb::File::File(const char* path,size_t version,const char *domain){ authdb::File::File(const char* path,size_t version,const char *domain) : _filePath(path) { #ifdef Windows // Attempt to open the file. _FileDes = INVALID_HANDLE_VALUE; Loading Loading @@ -619,3 +619,21 @@ void authdb::File::vacuum(){ ::write(_FileDes, &head, sizeof(head)); #endif } void authdb::File::purge(){ #ifdef Windows if(_FileDes != INVALID_HANDLE_VALUE){ CloseHandle(_FileDes); _FileDes = INVALID_HANDLE_VALUE; } DeleteFileA(_filePath.c_str()); DeleteFileA(_lockFile.c_str()); #else if(_FileDes >= 0){ close(_FileDes); _FileDes = -1; } unlink(_filePath.c_str()); unlink(_lockFile.c_str()); #endif }
src/backends/file.h +2 −0 Original line number Diff line number Diff line Loading @@ -63,7 +63,9 @@ namespace authdb { void newRevesion(); void vacuum(); void purge() override; private: std::string _filePath; std::string _lockFile; #ifdef Windows Loading
src/domain.cpp +0 −25 Original line number Diff line number Diff line Loading @@ -90,32 +90,7 @@ void authdb::Domain::create(authdb::AuthBackend& backend,class DomainData *data) } void authdb::Domain::remove(AuthBackend& backend, const uuid::uuid &uid){ AuthBackend::Guard guard(backend); authdb::AuthData::Record cur; size_t rd=sizeof(authdb::AuthHeader),end=backend.end(); while(rd+sizeof(AuthData::Record)<=end){ backend.setPos(rd); backend.read((unsigned char*)&cur,sizeof(AuthData::Record)); size_t next=backend.getPos()+cur.datasize; if(next<backend.getPos() || next>end) break; rd=next; if( uid==cur.ruid && cur.type==DataType::DomainData && strcmp(cur.fieldname,"domainoptions")==0){ cur.data=new char[cur.datasize]; backend.read((unsigned char*)cur.data,cur.datasize); unlink(cur.data); delete[] cur.data; } } backend.delRecord(uid,DataType::DomainData); } Loading