summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib/runtime/gr_unittests.h
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-01-18 01:00:15 -0800
committerJosh Blum <josh@joshknows.com>2011-01-18 01:00:15 -0800
commit05cc02cec03507c47846a668c92e6dcc4ba2e71e (patch)
tree8576c0c9977400aaaf26470766b6e9c9c3e83ce3 /gnuradio-core/src/lib/runtime/gr_unittests.h
parent31bbbec88b19230eb37b197d7623c3671e57837e (diff)
cleanup mkdir usage with boost filesystem:
Replaced copy/pasted code and MKDIR_TAKES_ONE_ARG #ifdefs with portable boost filesystem path and directory creation. Gets the correct home directory on windows systems: APPDATA. Replaces large amounts of copypasta with single lines of code. Removes MKDIR_TAKES_ONE_ARG configuration checks from m4 files. Adds boost filesystem and system library as build dependencies.
Diffstat (limited to 'gnuradio-core/src/lib/runtime/gr_unittests.h')
-rw-r--r--gnuradio-core/src/lib/runtime/gr_unittests.h38
1 files changed, 6 insertions, 32 deletions
diff --git a/gnuradio-core/src/lib/runtime/gr_unittests.h b/gnuradio-core/src/lib/runtime/gr_unittests.h
index 70aa6f294b..6e62bc7c1b 100644
--- a/gnuradio-core/src/lib/runtime/gr_unittests.h
+++ b/gnuradio-core/src/lib/runtime/gr_unittests.h
@@ -31,37 +31,11 @@
#include <sys/stat.h>
#include <unistd.h>
+#include <boost/filesystem/operations.hpp>
+#include <boost/filesystem/path.hpp>
-#ifdef MKDIR_TAKES_ONE_ARG
-#define gr_mkdir(pathname, mode) mkdir(pathname)
-#else
-#define gr_mkdir(pathname, mode) mkdir((pathname), (mode))
-#endif
-
-/*
- * Mostly taken from gr_preferences.cc/h
- * The simplest thing that could possibly work:
- * the key is the filename; the value is the file contents.
- */
-
-static void
-ensure_unittest_path (const char *path)
-{
- struct stat statbuf;
- if (stat (path, &statbuf) == 0 && S_ISDIR (statbuf.st_mode))
- return;
-
- // blindly try to make it // FIXME make this robust. C++ SUCKS!
- gr_mkdir (path, 0750);
+static std::string get_unittest_path(const std::string &filename){
+ boost::filesystem::path path = boost::filesystem::current_path() / ".unittests";
+ if (!boost::filesystem::is_directory(path)) boost::filesystem::create_directory(path);
+ return (path / filename).string();
}
-
-static void
-get_unittest_path (const char *filename, char *fullpath, size_t pathsize)
-{
- char path[200];
- snprintf (path, sizeof(path), "./.unittests");
- snprintf (fullpath, pathsize, "%s/%s", path, filename);
-
- ensure_unittest_path(path);
-}
-