Root/
| 1 | #ifdef ENABLE_INOTIFY |
| 2 | #include <sys/inotify.h> |
| 3 | #include <SDL/SDL.h> |
| 4 | #include <unistd.h> |
| 5 | |
| 6 | #include "debug.h" |
| 7 | #include "inputmanager.h" |
| 8 | #include "mediamonitor.h" |
| 9 | #include "utilities.h" |
| 10 | |
| 11 | MediaMonitor::MediaMonitor(std::string dir) : |
| 12 | Monitor(dir, IN_MOVE | IN_DELETE | IN_CREATE | IN_ONLYDIR) |
| 13 | { |
| 14 | } |
| 15 | |
| 16 | bool MediaMonitor::event_accepted( |
| 17 | struct inotify_event &event __attribute__((unused))) |
| 18 | { |
| 19 | return true; |
| 20 | } |
| 21 | |
| 22 | void MediaMonitor::inject_event(bool is_add, const char *path) |
| 23 | { |
| 24 | /* Sleep for a bit, to ensure that the media will be mounted |
| 25 | * on the mountpoint before we start looking for OPKs */ |
| 26 | sleep(1); |
| 27 | |
| 28 | if (is_add) |
| 29 | inject_user_event(OPEN_PACKAGES_FROM_DIR, strdup(path)); |
| 30 | else |
| 31 | inject_user_event(REMOVE_LINKS, strdup(path)); |
| 32 | } |
| 33 | |
| 34 | #endif /* ENABLE_INOTIFY */ |
| 35 |
Branches:
install_locations
master
opkrun
packages
