Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::mutex delete_m;
- std::string deleteSong(std::string fname)
- {
- if(fname.find(".") != std::string::npos || fname.find("//") != std::string::npos)
- {
- return "badparams";
- }
- std::lock_guard<std::mutex> lok(delete_m);
- sqlite3_stmt *res;
- char *sql = "DELETE FROM Music WHERE id = ?";
- sqlite3_prepare_v2(db, sql, -1, &res, 0);
- sqlite3_bind_text(res, 1, fname.c_str(), -1, 0);
- sqlite3_step(res);
- sqlite3_finalize(res);
- std::string path("plugins/hemirt-bot/music/");
- path.append(fname);
- path.append(".m4a");
- int rc = std::remove(path.c_str());
- if(rc == 0)
- {
- return "deleted";
- }
- else
- {
- std::stringstream ss;
- ss << rc;
- return ss.str();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement