diff options
author | Robin Gareus <robin@gareus.org> | 2014-02-27 01:35:57 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2014-02-28 00:05:47 +0100 |
commit | 3cf5dcb64cc1f7d552bc22c5564896c1fbf3d2d0 (patch) | |
tree | 5774288210c70ec2c52db1dd973f79da47025252 /libs/pbd/pathexpand.cc | |
parent | f8ec1d1f27c08c6d186f048f73630ca8ce25574a (diff) |
move Paths Dialog to libgtkmm2ext
Diffstat (limited to 'libs/pbd/pathexpand.cc')
-rw-r--r-- | libs/pbd/pathexpand.cc | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/libs/pbd/pathexpand.cc b/libs/pbd/pathexpand.cc index 3398bd1152..e9bef4c4aa 100644 --- a/libs/pbd/pathexpand.cc +++ b/libs/pbd/pathexpand.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Paul Davis + Copyright (C) 2013-2014 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,10 +25,12 @@ #include <regex.h> +#include <glibmm/fileutils.h> #include <glibmm/miscutils.h> #include "pbd/pathexpand.h" #include "pbd/strsplit.h" +#include "pbd/tokenizer.h" using std::string; using std::vector; @@ -192,3 +194,29 @@ PBD::search_path_expand (string path) return r; } + +std::vector <std::string> +PBD::parse_path(std::string path, bool check_if_exists) +{ + vector <std::string> pathlist; + vector <std::string> tmp; + PBD::tokenize (path, string(G_SEARCHPATH_SEPARATOR_S), std::back_inserter (tmp)); + + for(vector<std::string>::const_iterator i = tmp.begin(); i != tmp.end(); ++i) { + if ((*i).empty()) continue; + std::string dir; +#ifndef PLATFORM_WINDOWS + if ((*i).substr(0,1) == "~") { + dir = Glib::build_filename(Glib::get_home_dir(), (*i).substr(1)); + } + else +#endif + { + dir = *i; + } + if (!check_if_exists || Glib::file_test (dir, Glib::FILE_TEST_IS_DIR)) { + pathlist.push_back(dir); + } + } + return pathlist; +} |