From f1451b2670787cb9695dd4f3ad119d14c4208439 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 13 May 2014 18:58:15 -0400 Subject: [PATCH] Hooks - Enumerates installed hook scripts and sorts it, thus defining the execution sequence. --- src/Hooks.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Hooks.cpp b/src/Hooks.cpp index 237c8250d..6f1d0d2b6 100644 --- a/src/Hooks.cpp +++ b/src/Hooks.cpp @@ -25,6 +25,7 @@ //////////////////////////////////////////////////////////////////////////////// #include +#include #include #include @@ -45,8 +46,13 @@ void Hooks::initialize () { // Scan /hooks Directory d (context.config.get ("data.location")); - if (d.cd ("hooks")) + d += "hooks"; + if (d.is_directory () && + d.readable ()) + { _scripts = d.list (); + std::sort (_scripts.begin (), _scripts.end ()); + } } //////////////////////////////////////////////////////////////////////////////// @@ -70,5 +76,4 @@ void Hooks::onExit () context.timer_hooks.stop (); } -// TODO Time the hook runs. ////////////////////////////////////////////////////////////////////////////////