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;
285 std::error_code setCurrentWorkingDirectory(const Twine &Path) override;
286 std::error_code isLocal(const Twine &Path, bool &Result) override;
287 std::error_code getRealPath(const Twine &Path,
295 // If this FS has its own working dir, use it to make Path absolute.
296 // The returned twine is safe to use as long as both Storage and Path live.
297 Twine adjustPath(const Twine &Path, SmallVectorImpl<char> &Storage) const {
299 return Path;
300 Path.toVector(Storage);
316 ErrorOr<Status> RealFileSystem::status(const Twine &Path) {
320 sys::fs::status(adjustPath(Path, Storage), RealStatus))
322 return Status::copyWithNewName(RealStatus, Path);
348 std::error_code RealFileSystem::setCurrentWorkingDirectory(const Twine &Path) {
350 return llvm::sys::fs::set_current_path(Path);
353 adjustPath(Path, Storage).toVector(Absolute);
365 std::error_code RealFileSystem::isLocal(const Twine &Path, bool &Result) {
367 return llvm::sys::fs::is_local(adjustPath(Path, Storage), Result);
370 std::error_code RealFileSystem::getRealPath(const Twine &Path,
373 return llvm::sys::fs::real_path(adjustPath(Path, Storage), Output);
402 RealFSDirIter(const Twine &Path, std::error_code &EC) : Iter(Path, EC) {
441 ErrorOr<Status> OverlayFileSystem::status(const Twine &Path) {
444 ErrorOr<Status> Status = (*I)->status(Path);
451 bool OverlayFileSystem::exists(const Twine &Path) {
454 if ((*I)->exists(Path))
461 OverlayFileSystem::openFileForRead(const llvm::Twine &Path) {
464 auto Result = (*I)->openFileForRead(Path);
478 OverlayFileSystem::setCurrentWorkingDirectory(const Twine &Path) {
480 if (std::error_code EC = FS->setCurrentWorkingDirectory(Path))
485 std::error_code OverlayFileSystem::isLocal(const Twine &Path, bool &Result) {
487 if (FS->exists(Path))
488 return FS->isLocal(Path, Result);
492 std::error_code OverlayFileSystem::getRealPath(const Twine &Path,
495 if (FS->exists(Path))
496 return FS->getRealPath(Path, Output);
678 InMemoryHardLink(StringRef Path, const InMemoryFile &ResolvedFile)
679 : InMemoryNode(Path, IME_HardLink), ResolvedFile(ResolvedFile) {}
701 InMemorySymbolicLink(StringRef Path, StringRef TargetPath, Status Stat)
702 : InMemoryNode(Path, IME_SymbolicLink), TargetPath(std::move(TargetPath)),
747 void setPath(const Twine &Path) override { RequestedName = Path.str(); }
822 return Status(Path, UID, llvm::sys::toTimePoint(ModificationTime), User,
847 SmallString<128> Path;
848 P.toVector(Path);
851 std::error_code EC = makeAbsolute(Path);
856 llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
858 if (Path.empty())
862 auto I = llvm::sys::path::begin(Path), E = sys::path::end(Path);
881 StringRef(Path.str().begin(), Name.end() - Path.str().begin()),
897 MakeNode({Dir->getUniqueID(), Path, Name, ModificationTime,
957 SmallString<128> Path;
958 P.toVector(Path);
961 std::error_code EC = makeAbsolute(Path);
966 llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
969 if (Path.empty())
970 return detail::NamedNodeOrError(Path, Dir);
972 auto I = llvm::sys::path::begin(Path), E = llvm::sys::path::end(Path);
983 return detail::NamedNodeOrError(Path, Symlink);
1012 return detail::NamedNodeOrError(Path, File);
1019 return detail::NamedNodeOrError(Path, &File->getResolvedFile());
1025 return detail::NamedNodeOrError(Path, Dir);
1043 NNI.Path.str(),
1068 llvm::ErrorOr<Status> InMemoryFileSystem::status(const Twine &Path) {
1069 auto Node = lookupNode(Path, /*FollowFinalSymlink=*/true);
1071 return (*Node)->getStatus(Path);
1076 InMemoryFileSystem::openFileForRead(const Twine &Path) {
1077 auto Node = lookupNode(Path,/*FollowFinalSymlink=*/true);
1085 new detail::InMemoryFileAdaptor(*F, Path.str()));
1100 SmallString<256> Path(RequestedDirName);
1101 llvm::sys::path::append(Path, I->second->getFileName());
1113 FS->lookupNode(Path, /*FollowFinalSymlink=*/true)) {
1114 Path = SymlinkTarget.getName();
1115 Type = (*SymlinkTarget)->getStatus(Path).getType();
1119 CurrentEntry = directory_entry(std::string(Path), Type);
1162 SmallString<128> Path;
1163 P.toVector(Path);
1166 std::error_code EC = makeAbsolute(Path);
1171 llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
1173 if (!Path.empty())
1174 WorkingDirectory = std::string(Path);
1178 std::error_code InMemoryFileSystem::getRealPath(const Twine &Path,
1183 Path.toVector(Output);
1190 std::error_code InMemoryFileSystem::isLocal(const Twine &Path, bool &Result) {
1210 static llvm::sys::path::Style getExistingStyle(llvm::StringRef Path) {
1213 const size_t n = Path.find_first_of("/\\");
1216 style = (Path[n] == '/') ? llvm::sys::path::Style::posix
1222 static llvm::SmallString<256> canonicalize(llvm::StringRef Path) {
1224 llvm::sys::path::Style style = getExistingStyle(Path);
1229 llvm::sys::path::remove_leading_dotslash(Path, style);
1288 const Twine &Path, RedirectingFileSystem::DirectoryEntry::iterator Begin,
1290 : Dir(Path.str()), Current(Begin), End(End) {
1346 RedirectingFileSystem::setCurrentWorkingDirectory(const Twine &Path) {
1348 if (!exists(Path))
1352 Path.toVector(AbsolutePath);
1361 SmallString<256> Path;
1362 Path_.toVector(Path);
1364 if (makeAbsolute(Path))
1367 return ExternalFS->isLocal(Path, Result);
1370 std::error_code RedirectingFileSystem::makeAbsolute(SmallVectorImpl<char> &Path) const {
1372 if (llvm::sys::path::is_absolute(Path, llvm::sys::path::Style::posix) ||
1373 llvm::sys::path::is_absolute(Path,
1384 return makeAbsolute(WorkingDir.get(), Path);
1389 SmallVectorImpl<char> &Path) const {
1393 // append Path ourselves.
1418 // `Path` should be directly appended to `WorkingDir` without converting
1420 Result.append(Path.data(), Path.size());
1421 Path.assign(Result.begin(), Result.end());
1428 SmallString<256> Path;
1429 Dir.toVector(Path);
1431 EC = makeAbsolute(Path);
1435 ErrorOr<RedirectingFileSystem::LookupResult> Result = lookupPath(Path);
1439 return ExternalFS->dir_begin(Path, EC);
1446 ErrorOr<Status> S = status(Path, Dir, *Result);
1473 std::string(Path), RedirectIter));
1479 Path, DE->contents_begin(), DE->contents_end(), RedirectEC));
1496 directory_iterator ExternalIter = ExternalFS->dir_begin(Path, ExternalEC);
2282 SmallVectorImpl<char> &Path) const {
2283 if (std::error_code EC = makeAbsolute(Path))
2287 canonicalize(StringRef(Path.data(), Path.size()));
2291 Path.assign(CanonicalPath.begin(), CanonicalPath.end());
2296 RedirectingFileSystem::lookupPath(StringRef Path) const {
2297 llvm::SmallString<128> CanonicalPath(Path);
2415 SmallString<256> Path;
2416 OriginalPath.toVector(Path);
2418 if (std::error_code EC = makeAbsolute(Path))
2424 ErrorOr<Status> S = getExternalStatus(Path, OriginalPath);
2429 ErrorOr<RedirectingFileSystem::LookupResult> Result = lookupPath(Path);
2435 return getExternalStatus(Path, OriginalPath);
2439 ErrorOr<Status> S = status(Path, OriginalPath, *Result);
2445 return getExternalStatus(Path, OriginalPath);
2452 SmallString<256> Path;
2453 OriginalPath.toVector(Path);
2455 if (makeAbsolute(Path))
2461 if (ExternalFS->exists(Path))
2465 ErrorOr<RedirectingFileSystem::LookupResult> Result = lookupPath(Path);
2471 return ExternalFS->exists(Path);
2492 return ExternalFS->exists(Path);
2520 void setPath(const Twine &Path) override { S = S.copyWithNewName(S, Path); }
2541 SmallString<256> Path;
2542 OriginalPath.toVector(Path);
2544 if (std::error_code EC = makeAbsolute(Path))
2550 auto F = File::getWithPath(ExternalFS->openFileForRead(Path), OriginalPath);
2555 ErrorOr<RedirectingFileSystem::LookupResult> Result = lookupPath(Path);
2561 return File::getWithPath(ExternalFS->openFileForRead(Path), OriginalPath);
2583 return File::getWithPath(ExternalFS->openFileForRead(Path), OriginalPath);
2603 SmallString<256> Path;
2604 OriginalPath.toVector(Path);
2606 if (std::error_code EC = makeAbsolute(Path))
2612 std::error_code EC = ExternalFS->getRealPath(Path, Output);
2617 ErrorOr<RedirectingFileSystem::LookupResult> Result = lookupPath(Path);
2623 return ExternalFS->getRealPath(Path, Output);
2636 return ExternalFS->getRealPath(Path, Output);
2661 SmallVectorImpl<StringRef> &Path,
2669 Path.push_back(SubEntry->getName());
2670 getVFSEntries(SubEntry.get(), Path, Entries);
2671 Path.pop_back();
2680 for (auto &Comp : Path)
2691 for (auto &Comp : Path)
2749 bool containedIn(StringRef Parent, StringRef Path);
2750 StringRef containedPart(StringRef Parent, StringRef Path);
2751 void startDirectory(StringRef Path);
2766 bool JSONWriter::containedIn(StringRef Parent, StringRef Path) {
2771 for (auto IChild = path::begin(Path), EChild = path::end(Path);
2780 StringRef JSONWriter::containedPart(StringRef Parent, StringRef Path) {
2782 assert(containedIn(Parent, Path));
2783 return Path.slice(Parent.size() + 1, StringRef::npos);
2786 void JSONWriter::startDirectory(StringRef Path) {
2788 DirStack.empty() ? Path : containedPart(DirStack.back(), Path);
2789 DirStack.push_back(Path);
2911 FileSystem &FS_, const Twine &Path, std::error_code &EC)
2913 directory_iterator I = FS->dir_begin(Path, EC);