root directory is 2, not 1.

This commit is contained in:
Kelvin Sherlock 2015-01-15 14:11:55 -05:00
parent cc477e0865
commit 6c8511838e

View File

@ -5,6 +5,8 @@
namespace OS {
const int RootPathID = 2;
std::deque<FSSpecManager::Entry> FSSpecManager::_pathQueue;
void FSSpecManager::Init()
@ -49,7 +51,9 @@ namespace OS {
Init();
int i = 1;
// this only works well for a small number of directories,
// which should be the common case.
int i = RootPathID;
for (const auto &e : _pathQueue)
{
if (e.hash == hash && e.path == path) return i;
@ -82,7 +86,7 @@ namespace OS {
Init();
int i = 1;
int i = RootPathID;
for (const auto &e : _pathQueue)
{
if (e.hash == hash && e.path == path) return i;
@ -102,10 +106,11 @@ namespace OS {
Init();
if (id < 1) return NullString;
if (id > _pathQueue.size()) return NullString;
id -= RootPathID;
if (id < 0) return NullString;
if (id >= _pathQueue.size()) return NullString;
return _pathQueue[id - 1].path;
return _pathQueue[id].path;
}
std::string FSSpecManager::ExpandPath(const std::string &path, int32_t id)