[med-svn] [aghermann] 04/31: correctly correct subdir element when constructing CStorablePPack::path()

andrei zavada hmmr-guest at alioth.debian.org
Sun Nov 10 00:34:14 UTC 2013


This is an automated email from the git hooks/post-receive script.

hmmr-guest pushed a commit to branch WIP
in repository aghermann.

commit 62b13f7799211f633561613acb1adc5416154dbd
Author: andrei zavada <hmmr at fa2>
Date:   Fri Nov 8 19:34:35 2013 +0200

    correctly correct subdir element when constructing CStorablePPack::path()
---
 upstream/src/aghermann/expdesign/dirlevel.cc  |   25 ++++++++++++++++++++++++-
 upstream/src/aghermann/expdesign/dirlevel.hh  |    6 ++++++
 upstream/src/aghermann/expdesign/expdesign.hh |    2 +-
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/upstream/src/aghermann/expdesign/dirlevel.cc b/upstream/src/aghermann/expdesign/dirlevel.cc
index 5c3cb43..690fcf1 100644
--- a/upstream/src/aghermann/expdesign/dirlevel.cc
+++ b/upstream/src/aghermann/expdesign/dirlevel.cc
@@ -51,12 +51,35 @@ exp_dir_level_s( TExpDirLevel x)
 
 
 
+string
+agh::
+level_corrected_subdir( TExpDirLevel level, const string& subdir)
+{
+        auto undot = [] ( const string& S) -> string { return (S[0] == '.') ? string(S).erase(0,1) : S; };
+        switch (level) {
+        case TExpDirLevel::user:
+        case TExpDirLevel::system:
+                return undot(subdir);
+
+        case TExpDirLevel::transient:
+        case TExpDirLevel::session:
+        case TExpDirLevel::subject:
+        case TExpDirLevel::group:
+        case TExpDirLevel::experiment:
+        default:
+                return subdir;
+        }
+}
+
+
+
 
 string
 CStorablePPack::
 path() const
 {
-        string append = string("/") + subdir + "/" + name;
+        string append = string("/") + level_corrected_subdir() + "/" + name;
+
         switch (level) {
         case TExpDirLevel::transient:
                 return move(string("/tmp") + append);
diff --git a/upstream/src/aghermann/expdesign/dirlevel.hh b/upstream/src/aghermann/expdesign/dirlevel.hh
index e7b01cc..3106c7c 100644
--- a/upstream/src/aghermann/expdesign/dirlevel.hh
+++ b/upstream/src/aghermann/expdesign/dirlevel.hh
@@ -48,6 +48,8 @@ struct SExpDirLevelId {
 
 const char* exp_dir_level_s( agh::TExpDirLevel);
 
+string level_corrected_subdir( agh::TExpDirLevel, const string&);
+
 
 class CStorablePPack {
     public:
@@ -88,6 +90,10 @@ class CStorablePPack {
                 name;
         TExpDirLevel
                 level;
+        string
+        level_corrected_subdir() const
+                { return agh::level_corrected_subdir( level, subdir); }
+
         const char*
         exp_dir_level_s() const
                 { return agh::exp_dir_level_s(level); }
diff --git a/upstream/src/aghermann/expdesign/expdesign.hh b/upstream/src/aghermann/expdesign/expdesign.hh
index e56276d..3699950 100644
--- a/upstream/src/aghermann/expdesign/expdesign.hh
+++ b/upstream/src/aghermann/expdesign/expdesign.hh
@@ -331,7 +331,7 @@ load_profiles_from_location( const string& subdir,
 {
         list<T> ret;
 
-        string location = ED.make_dirname( level, level_id) + '/' + subdir;
+        string location = ED.make_dirname( level, level_id) + '/' + agh::level_corrected_subdir( level, subdir);
 
         struct dirent **eps;
         int     total = scandir( location.c_str(), &eps, simple_scandir_filter, alphasort);

-- 
Alioth's /git/debian-med/git-commit-notice on /srv/git.debian.org/git/debian-med/aghermann.git



More information about the debian-med-commit mailing list