//===----------------------------------------------------------------------===//
#include "clang/Basic/VirtualFileSystem.h"
-#include "clang/Basic/FileManager.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
assert(!EC);
(void)EC;
- FileManager::removeDotPaths(Path, /*RemoveDotDot=*/false);
- if (Path.empty())
- return;
-
detail::InMemoryDirectory *Dir = Root.get();
auto I = llvm::sys::path::begin(Path), E = llvm::sys::path::end(Path);
+ if (*I == ".")
+ ++I;
+
+ if (I == E)
+ return;
+
while (true) {
StringRef Name = *I;
detail::InMemoryNode *Node = Dir->getChild(Name);
assert(!EC);
(void)EC;
- FileManager::removeDotPaths(Path, /*RemoveDotDot=*/false);
- if (Path.empty())
+ auto I = llvm::sys::path::begin(Path), E = llvm::sys::path::end(Path);
+ if (*I == ".")
+ ++I;
+
+ if (I == E)
return Dir;
- auto I = llvm::sys::path::begin(Path), E = llvm::sys::path::end(Path);
while (true) {
detail::InMemoryNode *Node = Dir->getChild(*I);
++I;
FS.addFile("/a", 0, MemoryBuffer::getMemBuffer("a"));
auto Stat = FS.status("/");
ASSERT_FALSE(Stat.getError()) << Stat.getError() << FS.toString();
- Stat = FS.status("/.");
- ASSERT_FALSE(Stat.getError()) << Stat.getError() << FS.toString();
Stat = FS.status("/a");
ASSERT_FALSE(Stat.getError()) << Stat.getError() << "\n" << FS.toString();
ASSERT_EQ("/a", Stat->getName());
TEST_F(InMemoryFileSystemTest, OpenFileForRead) {
FS.addFile("/a", 0, MemoryBuffer::getMemBuffer("a"));
- FS.addFile("././c", 0, MemoryBuffer::getMemBuffer("c"));
+ FS.addFile("./c", 0, MemoryBuffer::getMemBuffer("c"));
auto File = FS.openFileForRead("/a");
ASSERT_EQ("a", (*(*File)->getBuffer("ignored"))->getBuffer());
File = FS.openFileForRead("/a"); // Open again.
ASSERT_EQ("a", (*(*File)->getBuffer("ignored"))->getBuffer());
- File = FS.openFileForRead("/././a"); // Open again.
+ File = FS.openFileForRead("./a"); // Open again.
ASSERT_EQ("a", (*(*File)->getBuffer("ignored"))->getBuffer());
File = FS.openFileForRead("/");
ASSERT_EQ(File.getError(), errc::invalid_argument) << FS.toString();
File = FS.openFileForRead("/b");
ASSERT_EQ(File.getError(), errc::no_such_file_or_directory) << FS.toString();
- File = FS.openFileForRead("./c");
+ File = FS.openFileForRead("c");
ASSERT_EQ("c", (*(*File)->getBuffer("ignored"))->getBuffer());
}