/[svn]/linuxsampler/trunk/src/common/Path.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/common/Path.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2528 by iliev, Fri Oct 23 17:53:17 2009 UTC revision 2529 by schoenebeck, Tue Mar 4 20:41:47 2014 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2   *                                                                         *   *                                                                         *
3   *   Copyright (C) 2007 Christian Schoenebeck                              *   *   Copyright (C) 2007-2014 Christian Schoenebeck                         *
4   *                                                                         *   *                                                                         *
5   *   This library is free software; you can redistribute it and/or modify  *   *   This library is free software; you can redistribute it and/or modify  *
6   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 27  Line 27 
27    
28  namespace LinuxSampler {  namespace LinuxSampler {
29    
30  Path::Path() : drive(0) {  Path::Path() : drive(0), absolute(false) {
31    }
32    
33    Path::Path(std::string path) {
34        #if WIN32
35        *this = fromWindows(path);
36        #else
37        *this = fromPosix(path);
38        #endif
39  }  }
40    
41  void Path::appendNode(std::string Name) {  void Path::appendNode(std::string Name) {
# Line 37  void Path::appendNode(std::string Name) Line 45  void Path::appendNode(std::string Name)
45    
46  void Path::setDrive(const char& Drive) {  void Path::setDrive(const char& Drive) {
47      drive = Drive;      drive = Drive;
48        absolute = true;
49  }  }
50    
51  std::string Path::toPosix() const {  std::string Path::toPosix() const {
# Line 188  Path Path::fromPosix(std::string path) { Line 197  Path Path::fromPosix(std::string path) {
197              s.replace(pos, 3, pcAscii);              s.replace(pos, 3, pcAscii);
198          }          }
199      }      }
200        // check whether given string reflects an absolute path
201        // (indicated by a forward slash as first character on POSIX)
202        result.absolute = !path.empty() && path[0] == '/';
203      return result;      return result;
204  }  }
205    
# Line 241  Path Path::fromWindows(std::string path) Line 253  Path Path::fromWindows(std::string path)
253          }          }
254      }      }
255    
256        // check whether given string reflects an absolute path
257        // (indicated either by a backslash or drive at the beginning on Windows)
258        result.absolute = result.drive || (!path.empty() && path[0] == '\\');
259    
260      return result;      return result;
261  }  }
262    
# Line 298  std::string Path::stripLastName(std::str Line 314  std::string Path::stripLastName(std::str
314      return p.stripLastName();      return p.stripLastName();
315  }  }
316    
317    bool Path::isAbsolute() const {
318        return absolute;
319    }
320    
321  } // namespace LinuxSampler  } // namespace LinuxSampler

Legend:
Removed from v.2528  
changed lines
  Added in v.2529

  ViewVC Help
Powered by ViewVC