Mercurial > fife-parpg
comparison engine/core/vfs/vfsdirectory.cpp @ 202:1d9154c535cf
fixed bug where the root directory path name was being added to the filename twice. It was initially added in the listFiles/listDirectories functions and then added again in the private function list. I modified the code so it is only added in the list function now.
author | vtchill@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 13 Mar 2009 03:05:14 +0000 |
parents | 3d0cc4545938 |
children | a3a044c586ab |
comparison
equal
deleted
inserted
replaced
201:a9c4b895ed02 | 202:1d9154c535cf |
---|---|
64 RawData* VFSDirectory::open(const std::string& file) const { | 64 RawData* VFSDirectory::open(const std::string& file) const { |
65 return new RawData(new RawDataFile(m_root + file)); | 65 return new RawData(new RawDataFile(m_root + file)); |
66 } | 66 } |
67 | 67 |
68 std::set<std::string> VFSDirectory::listFiles(const std::string& path) const { | 68 std::set<std::string> VFSDirectory::listFiles(const std::string& path) const { |
69 return list(path, false); | |
70 } | |
71 | |
72 std::set<std::string> VFSDirectory::listDirectories(const std::string& path) const { | |
73 return list(path, true); | |
74 } | |
75 | |
76 std::set<std::string> VFSDirectory::list(const std::string& path, bool directorys) const { | |
77 std::set<std::string> list; | |
69 std::string dir = m_root; | 78 std::string dir = m_root; |
79 | |
70 // Avoid double slashes | 80 // Avoid double slashes |
71 if(path[0] == '/' && m_root[m_root.size()-1] == '/') { | 81 if(path[0] == '/' && m_root[m_root.size()-1] == '/') { |
72 dir.append(path.substr(1)); | 82 dir.append(path.substr(1)); |
73 } | 83 } |
74 else { | 84 else { |
75 dir.append(path); | 85 dir.append(path); |
76 } | 86 } |
77 | 87 |
78 return list(dir, false); | 88 bfs::path boost_path(dir); |
79 } | |
80 | |
81 std::set<std::string> VFSDirectory::listDirectories(const std::string& path) const { | |
82 std::string dir = m_root; | |
83 // Avoid double slashes | |
84 if(path[0] == '/' && m_root[m_root.size()-1] == '/') { | |
85 dir.append(path.substr(1)); | |
86 } | |
87 else { | |
88 dir.append(path); | |
89 } | |
90 | |
91 return list(dir, true); | |
92 } | |
93 | |
94 std::set<std::string> VFSDirectory::list(const std::string& path, bool directorys) const { | |
95 std::set<std::string> list; | |
96 bfs::path boost_path(m_root + path); | |
97 if (!bfs::exists(boost_path) || !bfs::is_directory(boost_path)) | 89 if (!bfs::exists(boost_path) || !bfs::is_directory(boost_path)) |
98 return list; | 90 return list; |
99 | 91 |
100 bfs::directory_iterator end; | 92 bfs::directory_iterator end; |
101 for (bfs::directory_iterator i(boost_path); i != end; ++i) { | 93 for (bfs::directory_iterator i(boost_path); i != end; ++i) { |