Lines Matching defs:Path
35 #include "llvm/Support/Path.h"
128 std::error_code FileSystem::makeAbsolute(SmallVectorImpl<char> &Path) const {
129 if (llvm::sys::path::is_absolute(Path))
136 llvm::sys::fs::make_absolute(WorkingDir.get(), Path);
140 std::error_code FileSystem::getRealPath(const Twine &Path,
145 std::error_code FileSystem::isLocal(const Twine &Path, bool &Result) {
149 bool FileSystem::exists(const Twine &Path) {
150 auto Status = status(Path);
173 static bool pathHasTraversal(StringRef Path) {
176 for (StringRef Comp : llvm::make_range(path::begin(Path), path::end(Path)))
214 void setPath(const Twine &Path) override;
250 void RealFile::setPath(const Twine &Path) {
251 RealName = Path.str();
253 S = Status.get().copyWithNewName(Status.get(), Path);
280 ErrorOr<Status> status(const Twine &Path) override;
281 ErrorOr<std::unique_ptr<File>> openFileForRead(const Twine &Path) override;
283 openFileForReadBinary(const Twine &Path) override;
287 std::error_code setCurrentWorkingDirectory(const Twine &Path) override;
288 std::error_code isLocal(const Twine &Path, bool &Result) override;
289 std::error_code getRealPath(const Twine &Path,
297 // If this FS has its own working dir, use it to make Path absolute.
298 // The returned twine is safe to use as long as both Storage and Path live.
299 Twine adjustPath(const Twine &Path, SmallVectorImpl<char> &Storage) const {
301 return Path;
302 Path.toVector(Storage);
329 ErrorOr<Status> RealFileSystem::status(const Twine &Path) {
333 sys::fs::status(adjustPath(Path, Storage), RealStatus))
335 return Status::copyWithNewName(RealStatus, Path);
360 std::error_code RealFileSystem::setCurrentWorkingDirectory(const Twine &Path) {
362 return llvm::sys::fs::set_current_path(Path);
365 adjustPath(Path, Storage).toVector(Absolute);
377 std::error_code RealFileSystem::isLocal(const Twine &Path, bool &Result) {
379 return llvm::sys::fs::is_local(adjustPath(Path, Storage), Result);
382 std::error_code RealFileSystem::getRealPath(const Twine &Path,
385 return llvm::sys::fs::real_path(adjustPath(Path, Storage), Output);
414 RealFSDirIter(const Twine &Path, std::error_code &EC) : Iter(Path, EC) {
453 ErrorOr<Status> OverlayFileSystem::status(const Twine &Path) {
456 ErrorOr<Status> Status = (*I)->status(Path);
463 bool OverlayFileSystem::exists(const Twine &Path) {
466 if ((*I)->exists(Path))
473 OverlayFileSystem::openFileForRead(const llvm::Twine &Path) {
476 auto Result = (*I)->openFileForRead(Path);
490 OverlayFileSystem::setCurrentWorkingDirectory(const Twine &Path) {
492 if (std::error_code EC = FS->setCurrentWorkingDirectory(Path))
497 std::error_code OverlayFileSystem::isLocal(const Twine &Path, bool &Result) {
499 if (FS->exists(Path))
500 return FS->isLocal(Path, Result);
504 std::error_code OverlayFileSystem::getRealPath(const Twine &Path,
507 if (FS->exists(Path))
508 return FS->getRealPath(Path, Output);
690 InMemoryHardLink(StringRef Path, const InMemoryFile &ResolvedFile)
691 : InMemoryNode(Path, IME_HardLink), ResolvedFile(ResolvedFile) {}
713 InMemorySymbolicLink(StringRef Path, StringRef TargetPath, Status Stat)
714 : InMemoryNode(Path, IME_SymbolicLink), TargetPath(std::move(TargetPath)),
759 void setPath(const Twine &Path) override { RequestedName = Path.str(); }
834 return Status(Path, UID, llvm::sys::toTimePoint(ModificationTime), User,
859 SmallString<128> Path;
860 P.toVector(Path);
863 std::error_code EC = makeAbsolute(Path);
868 llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
870 if (Path.empty())
874 auto I = llvm::sys::path::begin(Path), E = sys::path::end(Path);
893 StringRef(Path.str().begin(), Name.end() - Path.str().begin()),
909 MakeNode({Dir->getUniqueID(), Path, Name, ModificationTime,
969 SmallString<128> Path;
970 P.toVector(Path);
973 std::error_code EC = makeAbsolute(Path);
978 llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
981 if (Path.empty())
982 return detail::NamedNodeOrError(Path, Dir);
984 auto I = llvm::sys::path::begin(Path), E = llvm::sys::path::end(Path);
995 return detail::NamedNodeOrError(Path, Symlink);
1024 return detail::NamedNodeOrError(Path, File);
1031 return detail::NamedNodeOrError(Path, &File->getResolvedFile());
1037 return detail::NamedNodeOrError(Path, Dir);
1055 NNI.Path.str(),
1080 llvm::ErrorOr<Status> InMemoryFileSystem::status(const Twine &Path) {
1081 auto Node = lookupNode(Path, /*FollowFinalSymlink=*/true);
1083 return (*Node)->getStatus(Path);
1088 InMemoryFileSystem::openFileForRead(const Twine &Path) {
1089 auto Node = lookupNode(Path,/*FollowFinalSymlink=*/true);
1097 new detail::InMemoryFileAdaptor(*F, Path.str()));
1112 SmallString<256> Path(RequestedDirName);
1113 llvm::sys::path::append(Path, I->second->getFileName());
1125 FS->lookupNode(Path, /*FollowFinalSymlink=*/true)) {
1126 Path = SymlinkTarget.getName();
1127 Type = (*SymlinkTarget)->getStatus(Path).getType();
1131 CurrentEntry = directory_entry(std::string(Path), Type);
1174 SmallString<128> Path;
1175 P.toVector(Path);
1178 std::error_code EC = makeAbsolute(Path);
1183 llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
1185 if (!Path.empty())
1186 WorkingDirectory = std::string(Path);
1190 std::error_code InMemoryFileSystem::getRealPath(const Twine &Path,
1195 Path.toVector(Output);
1202 std::error_code InMemoryFileSystem::isLocal(const Twine &Path, bool &Result) {
1222 static llvm::sys::path::Style getExistingStyle(llvm::StringRef Path) {
1225 const size_t n = Path.find_first_of("/\\");
1228 style = (Path[n] == '/') ? llvm::sys::path::Style::posix
1234 static llvm::SmallString<256> canonicalize(llvm::StringRef Path) {
1236 llvm::sys::path::Style style = getExistingStyle(Path);
1241 llvm::sys::path::remove_leading_dotslash(Path, style);
1300 const Twine &Path, RedirectingFileSystem::DirectoryEntry::iterator Begin,
1302 : Dir(Path.str()), Current(Begin), End(End) {
1358 RedirectingFileSystem::setCurrentWorkingDirectory(const Twine &Path) {
1360 if (!exists(Path))
1364 Path.toVector(AbsolutePath);
1373 SmallString<256> Path;
1374 Path_.toVector(Path);
1376 if (makeAbsolute(Path))
1379 return ExternalFS->isLocal(Path, Result);
1382 std::error_code RedirectingFileSystem::makeAbsolute(SmallVectorImpl<char> &Path) const {
1384 if (llvm::sys::path::is_absolute(Path, llvm::sys::path::Style::posix) ||
1385 llvm::sys::path::is_absolute(Path,
1396 return makeAbsolute(WorkingDir.get(), Path);
1401 SmallVectorImpl<char> &Path) const {
1405 // append Path ourselves.
1430 // `Path` should be directly appended to `WorkingDir` without converting
1432 Result.append(Path.data(), Path.size());
1433 Path.assign(Result.begin(), Result.end());
1440 SmallString<256> Path;
1441 Dir.toVector(Path);
1443 EC = makeAbsolute(Path);
1447 ErrorOr<RedirectingFileSystem::LookupResult> Result = lookupPath(Path);
1451 return ExternalFS->dir_begin(Path, EC);
1458 ErrorOr<Status> S = status(Path, Dir, *Result);
1485 std::string(Path), RedirectIter));
1491 Path, DE->contents_begin(), DE->contents_end(), RedirectEC));
1508 directory_iterator ExternalIter = ExternalFS->dir_begin(Path, ExternalEC);
2295 SmallVectorImpl<char> &Path) const {
2296 if (std::error_code EC = makeAbsolute(Path))
2300 canonicalize(StringRef(Path.data(), Path.size()));
2304 Path.assign(CanonicalPath.begin(), CanonicalPath.end());
2309 RedirectingFileSystem::lookupPath(StringRef Path) const {
2310 llvm::SmallString<128> CanonicalPath(Path);
2428 SmallString<256> Path;
2429 OriginalPath.toVector(Path);
2431 if (std::error_code EC = makeAbsolute(Path))
2437 ErrorOr<Status> S = getExternalStatus(Path, OriginalPath);
2442 ErrorOr<RedirectingFileSystem::LookupResult> Result = lookupPath(Path);
2448 return getExternalStatus(Path, OriginalPath);
2452 ErrorOr<Status> S = status(Path, OriginalPath, *Result);
2458 return getExternalStatus(Path, OriginalPath);
2465 SmallString<256> Path;
2466 OriginalPath.toVector(Path);
2468 if (makeAbsolute(Path))
2474 if (ExternalFS->exists(Path))
2478 ErrorOr<RedirectingFileSystem::LookupResult> Result = lookupPath(Path);
2484 return ExternalFS->exists(Path);
2505 return ExternalFS->exists(Path);
2533 void setPath(const Twine &Path) override { S = S.copyWithNewName(S, Path); }
2554 SmallString<256> Path;
2555 OriginalPath.toVector(Path);
2557 if (std::error_code EC = makeAbsolute(Path))
2563 auto F = File::getWithPath(ExternalFS->openFileForRead(Path), OriginalPath);
2568 ErrorOr<RedirectingFileSystem::LookupResult> Result = lookupPath(Path);
2574 return File::getWithPath(ExternalFS->openFileForRead(Path), OriginalPath);
2596 return File::getWithPath(ExternalFS->openFileForRead(Path), OriginalPath);
2616 SmallString<256> Path;
2617 OriginalPath.toVector(Path);
2619 if (std::error_code EC = makeAbsolute(Path))
2625 std::error_code EC = ExternalFS->getRealPath(Path, Output);
2630 ErrorOr<RedirectingFileSystem::LookupResult> Result = lookupPath(Path);
2636 return ExternalFS->getRealPath(Path, Output);
2649 return ExternalFS->getRealPath(Path, Output);
2674 SmallVectorImpl<StringRef> &Path,
2682 Path.push_back(SubEntry->getName());
2683 getVFSEntries(SubEntry.get(), Path, Entries);
2684 Path.pop_back();
2693 for (auto &Comp : Path)
2704 for (auto &Comp : Path)
2762 bool containedIn(StringRef Parent, StringRef Path);
2763 StringRef containedPart(StringRef Parent, StringRef Path);
2764 void startDirectory(StringRef Path);
2779 bool JSONWriter::containedIn(StringRef Parent, StringRef Path) {
2784 for (auto IChild = path::begin(Path), EChild = path::end(Path);
2793 StringRef JSONWriter::containedPart(StringRef Parent, StringRef Path) {
2795 assert(containedIn(Parent, Path));
2796 return Path.substr(Parent.size() + 1);
2799 void JSONWriter::startDirectory(StringRef Path) {
2801 DirStack.empty() ? Path : containedPart(DirStack.back(), Path);
2802 DirStack.push_back(Path);
2924 FileSystem &FS_, const Twine &Path, std::error_code &EC)
2926 directory_iterator I = FS->dir_begin(Path, EC);