Commit 1c994463116c3427589188e5f15e117d44bc188e

Authored by David Mayerich
1 parent 15a31763

fixed root directory bug in stim::filename

Showing 1 changed file with 10 additions and 5 deletions   Show diff stats
stim/parser/filename.h
... ... @@ -110,12 +110,17 @@ protected:
110 110 unix_dir = unix_dir.substr(2, unix_dir.length()-2); //extract the directory structure
111 111 }
112 112  
113   - if(unix_dir[0] == '/'){ //if there is a leading slash
114   - relative = false; //the path is not relative
115   - unix_dir = unix_dir.substr(1, unix_dir.length() - 1); //remove the slash
  113 + if(drive.size() != 0){
  114 + relative = false;
  115 + }
  116 + if(unix_dir.size() > 0){ //if there is a directory specified, remove surrounding slashes
  117 + if(unix_dir[0] == '/'){ //if there is a leading slash
  118 + relative = false; //the path is not relative
  119 + unix_dir = unix_dir.substr(1, unix_dir.length() - 1); //remove the slash
  120 + }
  121 + if(unix_dir[unix_dir.size()-1] == '/')
  122 + unix_dir = unix_dir.substr(0, unix_dir.length() - 1);
116 123 }
117   - if(unix_dir[unix_dir.size()-1] == '/')
118   - unix_dir = unix_dir.substr(0, unix_dir.length() - 1);
119 124  
120 125 path = stim::parser::split(unix_dir, '/'); //split up the directory structure
121 126  
... ...