}
}
-static int __open_write_db(uid_t uid, const char *path, sqlite3 **db, int flags) {
+static int __open_write_db(uid_t uid, const char* path,
+ sqlite3** db, int flags) {
int ret;
ret = sqlite3_open_v2(path, db, flags, NULL);
return ret;
}
- ret = sqlite3_busy_handler(*db, __writedb_busy_handler, (void *)path);
+ ret = sqlite3_busy_handler(*db, __writedb_busy_handler,
+ reinterpret_cast<void*>(const_cast<char*>(path)));
if (ret != SQLITE_OK) {
_LOGE("failed to register busy handler: %s",
sqlite3_errmsg(*db));
}
AbstractDBHandler::~AbstractDBHandler() {
- // Is this necessary?
for (auto db_handle : db_handle_list_)
sqlite3_close(db_handle.first);
}
std::vector<std::pair<std::string, uid_t>> AbstractDBHandler::GetDBPath() {
std::vector<std::pair<std::string, uid_t>> db_path;
- if (db_type_ == DB_TYPE_FILE_PKGDB) {
+ if (db_type_ == DB_TYPE_FILE_PKGDB)
db_path = DBHandleProvider::GetInst(uid_).GetParserDBPath(pid_);
- } else if (db_type_ == DB_TYPE_FILE_CERTDB) {
- db_path.emplace_back(std::make_pair(DBHandleProvider::GetInst(uid_).GetCertDBPath(pid_), uid_));
- }
+ else if (db_type_ == DB_TYPE_FILE_CERTDB)
+ db_path.emplace_back(
+ std::make_pair(
+ DBHandleProvider::GetInst(uid_).GetCertDBPath(pid_), uid_));
return db_path;
}
}
return true;
-/*
- if (op_type_ == OPERATION_TYPE_READ)
- ret = __open_read_db(db_path.c_str(), &db_, SQLITE_OPEN_READONLY |
- SQLITE_OPEN_URI);
- else
- ret = __open_write_db(uid_, db_path.c_str(), &db_,
- SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE);
-
- if (ret != SQLITE_OK) {
- // error log
- return false;
- }
- return true;
-*/
}
std::vector<std::pair<sqlite3*, uid_t>> AbstractDBHandler::GetConnection() {
void AbstractDBHandler::SetDBType(DBType type) { db_type_ = type; }
-AbstractDBHandler::OperationType AbstractDBHandler::GetOpType() { return op_type_; }
+AbstractDBHandler::OperationType AbstractDBHandler::GetOpType() {
+ return op_type_;
+}
} // namespace database
} // namespace pkgmgr_common