A 2D tile-based sandbox game.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "OS.h"
  2. #include <stdexcept>
  3. #include <unistd.h>
  4. #include <dlfcn.h>
  5. #include "log.h"
  6. namespace Swan {
  7. namespace OS {
  8. bool isTTY(FILE *f) {
  9. int fd = fileno(f);
  10. return isatty(fd);
  11. }
  12. Dynlib::Dynlib(const std::string &path) {
  13. handle_ = dlopen((path + ".so").c_str(), RTLD_LAZY);
  14. if (!handle_)
  15. throw std::runtime_error(dlerror());
  16. }
  17. Dynlib::Dynlib(Dynlib &&dl) noexcept: handle_(dl.handle_) {
  18. dl.handle_ = nullptr;
  19. }
  20. Dynlib::~Dynlib() {
  21. if (handle_)
  22. dlclose(handle_);
  23. }
  24. Dynlib &Dynlib::operator=(Dynlib &&dl) noexcept {
  25. handle_ = dl.handle_;
  26. dl.handle_ = nullptr;
  27. return *this;
  28. }
  29. void *Dynlib::getVoid(const std::string &name) {
  30. return dlsym(handle_, name.c_str());
  31. }
  32. }
  33. }