diff options
Diffstat (limited to 'gnuradio-core/src/lib')
-rw-r--r-- | gnuradio-core/src/lib/general/gri_fft.cc | 13 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/Makefile.am | 6 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_preferences.cc | 15 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_sys_paths.cc | 55 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_sys_paths.h (renamed from gnuradio-core/src/lib/runtime/gr_tmp_path.h) | 18 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_tmp_path.cc | 52 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_vmcircbuf_createfilemapping.cc | 3 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_vmcircbuf_mmap_shm_open.cc | 4 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_vmcircbuf_mmap_tmpfile.cc | 4 |
9 files changed, 79 insertions, 91 deletions
diff --git a/gnuradio-core/src/lib/general/gri_fft.cc b/gnuradio-core/src/lib/general/gri_fft.cc index 37be06f09..f20b15ca0 100644 --- a/gnuradio-core/src/lib/general/gri_fft.cc +++ b/gnuradio-core/src/lib/general/gri_fft.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2003,2008 Free Software Foundation, Inc. + * Copyright 2003,2008,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -21,6 +21,7 @@ */ #include <gri_fft.h> +#include <gr_sys_paths.h> #include <fftw3.h> #include <gr_complex.h> #include <stdlib.h> @@ -33,14 +34,6 @@ #include <boost/filesystem/path.hpp> namespace fs = boost::filesystem; -static std::string get_home_dir(void){ - #if defined(BOOST_WINDOWS) - return getenv ("APPDATA"); - #else - return getenv ("HOME"); - #endif -} - boost::mutex & gri_fft_planner::mutex() { @@ -53,7 +46,7 @@ static const char * wisdom_filename () { static fs::path path; - path = fs::path(get_home_dir()) / ".gr_fftw_wisdom"; + path = fs::path(gr_appdata_path()) / ".gr_fftw_wisdom"; return path.string().c_str(); } diff --git a/gnuradio-core/src/lib/runtime/Makefile.am b/gnuradio-core/src/lib/runtime/Makefile.am index 3dd2b42f5..eca92e526 100644 --- a/gnuradio-core/src/lib/runtime/Makefile.am +++ b/gnuradio-core/src/lib/runtime/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2003,2004,2007,2008,2009,2010 Free Software Foundation, Inc. +# Copyright 2003,2004,2007,2008,2009,2010,2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -58,7 +58,7 @@ libruntime_la_SOURCES = \ gr_sync_block.cc \ gr_sync_decimator.cc \ gr_sync_interpolator.cc \ - gr_tmp_path.cc \ + gr_sys_paths.cc \ gr_top_block.cc \ gr_top_block_impl.cc \ gr_tpb_detail.cc \ @@ -121,7 +121,7 @@ grinclude_HEADERS = \ gr_tpb_detail.h \ gr_tpb_thread_body.h \ gr_timer.h \ - gr_tmp_path.h \ + gr_sys_paths.h \ gr_types.h \ gr_unittests.h \ gr_vmcircbuf.h \ diff --git a/gnuradio-core/src/lib/runtime/gr_preferences.cc b/gnuradio-core/src/lib/runtime/gr_preferences.cc index 21934677b..c2ca047a8 100644 --- a/gnuradio-core/src/lib/runtime/gr_preferences.cc +++ b/gnuradio-core/src/lib/runtime/gr_preferences.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2003,2010 Free Software Foundation, Inc. + * Copyright 2003,2010,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -25,6 +25,7 @@ #endif #include <gr_preferences.h> +#include <gr_sys_paths.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -37,14 +38,6 @@ #include <boost/filesystem/path.hpp> namespace fs = boost::filesystem; -static std::string get_home_dir(void){ - #if defined(BOOST_WINDOWS) - return getenv ("APPDATA"); - #else - return getenv ("HOME"); - #endif -} - /* * The simplest thing that could possibly work: * the key is the filename; the value is the file contents. @@ -54,14 +47,14 @@ static const char * pathname (const char *key) { static fs::path path; - path = fs::path(get_home_dir()) / ".gnuradio" / "prefs" / key; + path = fs::path(gr_appdata_path()) / ".gnuradio" / "prefs" / key; return path.string().c_str(); } static void ensure_dir_path () { - fs::path path = fs::path(get_home_dir()) / ".gnuradio"; + fs::path path = fs::path(gr_appdata_path()) / ".gnuradio"; if (!fs::is_directory(path)) fs::create_directory(path); path = path / "prefs"; diff --git a/gnuradio-core/src/lib/runtime/gr_sys_paths.cc b/gnuradio-core/src/lib/runtime/gr_sys_paths.cc new file mode 100644 index 000000000..9d10a3ccd --- /dev/null +++ b/gnuradio-core/src/lib/runtime/gr_sys_paths.cc @@ -0,0 +1,55 @@ +/* + * Copyright 2011 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <gr_sys_paths.h> +#include <cstdlib> //getenv +#include <cstdio> //P_tmpdir (maybe) + +const char *gr_tmp_path(){ + const char *path; + + //first case, try TMP environment variable + path = getenv("TMP"); + if (path) return path; + + //second case, try P_tmpdir when its defined + #ifdef P_tmpdir + if (P_tmpdir) return P_tmpdir; + #endif /*P_tmpdir*/ + + //fall-through case, nothing worked + return "/tmp"; +} + +const char *gr_appdata_path(){ + const char *path; + + //first case, try HOME environment variable (unix) + path = getenv("HOME"); + if (path) return path; + + //second case, try APPDATA environment variable (windows) + path = getenv("APPDATA"); + if (path) return path; + + //fall-through case, nothing worked + return gr_tmp_path(); +} diff --git a/gnuradio-core/src/lib/runtime/gr_tmp_path.h b/gnuradio-core/src/lib/runtime/gr_sys_paths.h index 3d02043c7..aa8249775 100644 --- a/gnuradio-core/src/lib/runtime/gr_tmp_path.h +++ b/gnuradio-core/src/lib/runtime/gr_sys_paths.h @@ -1,6 +1,5 @@ -/* -*- c++ -*- */ /* - * Copyright 2003 Free Software Foundation, Inc. + * Copyright 2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,12 +19,13 @@ * Boston, MA 02110-1301, USA. */ -#ifndef _GR_TMP_PATH_H_ -#define _GR_TMP_PATH_H_ +#ifndef _GR_SYS_PATHS_H_ +#define _GR_SYS_PATHS_H_ -/*! - * \brief return directory portion of pathname used for temporary files. - */ -const char *gr_tmp_path (); +//! directory to create temporary files +const char *gr_tmp_path(); + +//! directory to store application data +const char *gr_appdata_path(); -#endif /* _GR_TMP_PATH_H_ */ +#endif /* _GR_SYS_PATHS_H_ */ diff --git a/gnuradio-core/src/lib/runtime/gr_tmp_path.cc b/gnuradio-core/src/lib/runtime/gr_tmp_path.cc deleted file mode 100644 index 1f0c830cd..000000000 --- a/gnuradio-core/src/lib/runtime/gr_tmp_path.cc +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include <gr_tmp_path.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -const char * -gr_tmp_path () -{ - static char *pp = 0; - - if (pp) - return pp; - - char *s = getenv ("TMP"); - if (s){ - pp = strdup (s); - return pp; - } - -#ifdef P_tmpdir - if (P_tmpdir){ - pp = strdup (P_tmpdir); - return pp; - } -#endif - - pp = strdup ("/tmp"); - return pp; -} - diff --git a/gnuradio-core/src/lib/runtime/gr_vmcircbuf_createfilemapping.cc b/gnuradio-core/src/lib/runtime/gr_vmcircbuf_createfilemapping.cc index 65fe0c488..42c459484 100644 --- a/gnuradio-core/src/lib/runtime/gr_vmcircbuf_createfilemapping.cc +++ b/gnuradio-core/src/lib/runtime/gr_vmcircbuf_createfilemapping.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2003,2005 Free Software Foundation, Inc. + * Copyright 2003,2005,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -36,7 +36,6 @@ #include <errno.h> #include <stdio.h> #include <gr_pagesize.h> -#include <gr_tmp_path.h> #include <gr_vmcircbuf_createfilemapping.h> #ifdef HAVE_CREATEFILEMAPPING diff --git a/gnuradio-core/src/lib/runtime/gr_vmcircbuf_mmap_shm_open.cc b/gnuradio-core/src/lib/runtime/gr_vmcircbuf_mmap_shm_open.cc index 3017036ef..4f7ae39cd 100644 --- a/gnuradio-core/src/lib/runtime/gr_vmcircbuf_mmap_shm_open.cc +++ b/gnuradio-core/src/lib/runtime/gr_vmcircbuf_mmap_shm_open.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2003 Free Software Foundation, Inc. + * Copyright 2003,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -37,7 +37,7 @@ #include <errno.h> #include <stdio.h> #include <gr_pagesize.h> -#include <gr_tmp_path.h> +#include <gr_sys_paths.h> gr_vmcircbuf_mmap_shm_open::gr_vmcircbuf_mmap_shm_open (int size) diff --git a/gnuradio-core/src/lib/runtime/gr_vmcircbuf_mmap_tmpfile.cc b/gnuradio-core/src/lib/runtime/gr_vmcircbuf_mmap_tmpfile.cc index faae4b396..ee8b0c485 100644 --- a/gnuradio-core/src/lib/runtime/gr_vmcircbuf_mmap_tmpfile.cc +++ b/gnuradio-core/src/lib/runtime/gr_vmcircbuf_mmap_tmpfile.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2003 Free Software Foundation, Inc. + * Copyright 2003,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -39,7 +39,7 @@ #include <stdio.h> #include <string.h> #include <gr_pagesize.h> -#include <gr_tmp_path.h> +#include <gr_sys_paths.h> gr_vmcircbuf_mmap_tmpfile::gr_vmcircbuf_mmap_tmpfile (int size) : gr_vmcircbuf (size) |