/[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 1332 by schoenebeck, Sun Sep 9 12:22:34 2007 UTC revision 1345 by iliev, Thu Sep 13 21:46:25 2007 UTC
# Line 35  std::string Path::toPosix() { Line 35  std::string Path::toPosix() {
35      // and http://www.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap03.html#tag_03_266 )      // and http://www.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap03.html#tag_03_266 )
36      std::string result;      std::string result;
37      for (int iElement = 0; iElement < elements.size(); iElement++) {      for (int iElement = 0; iElement < elements.size(); iElement++) {
38          // encode forward slashes          // encode percent characters
39          std::string e = elements[iElement];          std::string e = elements[iElement];
40          for (          for (
41                int pos = e.find("%"); pos != std::string::npos;
42                pos = e.find("%", pos+2)
43            ) e.replace(pos/*offset*/, 1/*length*/, "%%"/*by*/);
44            // encode forward slashes
45            for (
46              int pos = e.find("/"); pos != std::string::npos;              int pos = e.find("/"); pos != std::string::npos;
47              pos = e.find("/", pos+1)              pos = e.find("/", pos+3)
48          ) e.replace(pos/*offset*/, 1/*length*/, "%2f"/*by*/);          ) e.replace(pos/*offset*/, 1/*length*/, "%2f"/*by*/);
49          // append encoded node to full encoded path          // append encoded node to full encoded path
50          result += "/" + e;          result += "/" + e;
51      }      }
52        if (!result.size()) result = "/";
53        return result;
54    }
55    
56    std::string Path::toDbPath() {
57        std::string result;
58        for (int iElement = 0; iElement < elements.size(); iElement++) {
59            // replace all slashes with '\0'
60            std::string e = elements[iElement];
61            for (int i = 0; i < e.length(); i++) {
62                if (e.at(i) == '/') e.at(i) = '\0';
63            }
64            // append encoded node to full encoded path
65            result += "/" + e;
66        }
67      if (!result.size()) result = "/";      if (!result.size()) result = "/";
68      return result;      return result;
69  }  }

Legend:
Removed from v.1332  
changed lines
  Added in v.1345

  ViewVC Help
Powered by ViewVC