Advertisement
Hemirt

Untitled

Jul 29th, 2016
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. std::mutex delete_m;
  2. std::string deleteSong(std::string fname)
  3. {
  4. if(fname.find(".") != std::string::npos || fname.find("//") != std::string::npos)
  5. {
  6. return "badparams";
  7. }
  8. std::lock_guard<std::mutex> lok(delete_m);
  9. sqlite3_stmt *res;
  10. char *sql = "DELETE FROM Music WHERE id = ?";
  11. sqlite3_prepare_v2(db, sql, -1, &res, 0);
  12. sqlite3_bind_text(res, 1, fname.c_str(), -1, 0);
  13. sqlite3_step(res);
  14. sqlite3_finalize(res);
  15. std::string path("plugins/hemirt-bot/music/");
  16. path.append(fname);
  17. path.append(".m4a");
  18. int rc = std::remove(path.c_str());
  19. if(rc == 0)
  20. {
  21. return "deleted";
  22. }
  23. else
  24. {
  25. std::stringstream ss;
  26. ss << rc;
  27. return ss.str();
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement