Lines Matching +full:external +full:- +full:contents
1 //===- VirtualFileSystem.cpp - Virtual File System Layer --------*- C++ -*-===//
8 //===----------------------------------------------------------------------===//
10 //===----------------------------------------------------------------------===//
19 #include "llvm/Config/llvm-config.h"
101 return (*F)->getBuffer(Name, FileSize, RequiresNullTerminator, IsVolatile); in getBufferForFile()
117 return Status && Status->exists(); in exists()
134 //===-----------------------------------------------------------------------===/
136 //===-----------------------------------------------------------------------===/
166 assert(FD != -1 && "cannot stat closed file"); in status()
183 assert(FD != -1 && "cannot get buffer for closed file"); in getBuffer()
190 FD = -1; in close()
259 EC = Iter->status(S); in RealFSDirIter()
261 CurrentEntry = Status::copyWithNewName(S, Iter->path()); in RealFSDirIter()
274 EC = Iter->status(S); in increment()
275 CurrentEntry = Status::copyWithNewName(S, Iter->path()); in increment()
287 //===-----------------------------------------------------------------------===/
289 //===-----------------------------------------------------------------------===/
298 FS->setCurrentWorkingDirectory(getCurrentWorkingDirectory().get()); in pushOverlay()
304 ErrorOr<Status> Status = (*I)->status(Path); in status()
315 auto Result = (*I)->openFileForRead(Path); in openFileForRead()
325 return FSList.front()->getCurrentWorkingDirectory(); in getCurrentWorkingDirectory()
330 if (std::error_code EC = FS->setCurrentWorkingDirectory(Path)) in setCurrentWorkingDirectory()
350 CurrentDirIter = (*CurrentFS)->dir_begin(Path, EC); in incrementFS()
389 CurrentDirIter = (*CurrentFS)->dir_begin(Path, EC); in OverlayFSDirIterImpl()
437 return N->getKind() == IME_File; in classof()
454 Buf->getBuffer(), Buf->getBufferIdentifier(), RequiresNullTerminator); in getBuffer()
469 return I->second.get(); in getChild()
474 .first->second.get(); in addChild()
485 Result += Entry.second->toString(Indent + 2); in toString()
490 return N->getKind() == IME_Directory; in classof()
505 return Root->toString(/*Indent=*/0); in toString()
528 detail::InMemoryNode *Node = Dir->getChild(Name); in addFile()
536 Buffer->getBufferSize(), in addFile()
539 Dir->addChild(Name, llvm::make_unique<detail::InMemoryFile>( in addFile()
547 StringRef(Path.str().begin(), Name.end() - Path.str().begin()), in addFile()
549 0, 0, Buffer->getBufferSize(), in addFile()
551 Dir = cast<detail::InMemoryDirectory>(Dir->addChild( in addFile()
567 return cast<detail::InMemoryFile>(Node)->getBuffer()->getBuffer() == in addFile()
568 Buffer->getBuffer(); in addFile()
577 Buffer->getBuffer(), Buffer->getBufferIdentifier())); in addFileNoOwn()
599 detail::InMemoryNode *Node = Dir->getChild(*I); in lookupInMemoryNode()
621 return (*Node)->getStatus(); in status()
631 // When we have a file provide a heap-allocated wrapper for the memory buffer in openFileForRead()
651 CurrentEntry = I->second->getStatus(); in InMemoryDirIterator()
658 CurrentEntry = I != E ? I->second->getStatus() : Status(); in increment()
698 //===-----------------------------------------------------------------------===/
700 //===-----------------------------------------------------------------------===/
722 std::vector<std::unique_ptr<Entry>> Contents; member in __anon45e96e000711::RedirectingDirectoryEntry
727 std::vector<std::unique_ptr<Entry>> Contents, in RedirectingDirectoryEntry() argument
729 : Entry(EK_Directory, Name), Contents(std::move(Contents)), in RedirectingDirectoryEntry()
735 Contents.push_back(std::move(Content)); in addContent()
737 Entry *getLastContent() const { return Contents.back().get(); } in getLastContent()
738 typedef decltype(Contents)::iterator iterator;
739 iterator contents_begin() { return Contents.begin(); } in contents_begin()
740 iterator contents_end() { return Contents.end(); } in contents_end()
741 static bool classof(const Entry *E) { return E->getKind() == EK_Directory; } in classof()
760 /// \brief whether to use the external path as the name for this file.
766 static bool classof(const Entry *E) { return E->getKind() == EK_File; } in classof()
787 /// virtual file paths to existing external files, available in \c ExternalFS.
801 /// 'case-sensitive': <boolean, default=true>
802 /// 'use-external-names': <boolean, default=true>
803 /// 'overlay-relative': <boolean, default=false>
810 /// 'contents': [ <file or directory entries> ]
823 /// Re-mapped files are represented as
828 /// 'use-external-name': <boolean> # Optional
829 /// 'external-contents': <path to external file>)
833 /// and inherit their attributes from the external contents.
841 /// \brief The file system to use for external references.
844 /// path that should be prefixed to each 'external-contents' entry
851 /// \brief Whether to perform case-sensitive comparisons.
853 /// Currently, case-insensitive matching only works correctly with ASCII.
857 /// be prefixed in every 'external-contents' when reading from YAML files.
860 /// \brief Whether to use to use the value of 'external-contents' for the
861 /// names of files. This global value is overridable on a per-file basis.
865 /// Virtual file paths and external files could be canonicalized without "..",
885 /// recursing into the contents of \p From if it is a directory.
894 /// returns a virtual file system representing its contents.
904 return ExternalFS->getCurrentWorkingDirectory(); in getCurrentWorkingDirectory()
907 return ExternalFS->setCurrentWorkingDirectory(Path); in setCurrentWorkingDirectory()
921 if (!S->isDirectory()) { in dir_begin()
929 *this, D->contents_begin(), D->contents_end(), EC)); in dir_begin()
947 StringRef Name = E->getName(); in dumpEntry()
952 if (E->getKind() == EK_Directory) { in dumpEntry()
957 llvm::make_range(DE->contents_begin(), DE->contents_end())) in dumpEntry()
981 Result = S->getValue(Storage); in parseScalarString()
1034 if (I->second.Required && !I->second.Seen) { in checkMissingKeys()
1035 error(Obj, Twine("missing key '") + I->first + "'"); in checkMissingKeys()
1045 for (const std::unique_ptr<Entry> &Root : FS->Roots) { in lookupOrCreateEntry()
1046 if (Name.equals(Root->getName())) { in lookupOrCreateEntry()
1054 llvm::make_range(DE->contents_begin(), DE->contents_end())) { in lookupOrCreateEntry()
1056 if (DirContent && Name.equals(Content->getName())) in lookupOrCreateEntry()
1067 FS->Roots.push_back(std::move(E)); in lookupOrCreateEntry()
1068 ParentEntry = FS->Roots.back().get(); in lookupOrCreateEntry()
1073 DE->addContent(std::move(E)); in lookupOrCreateEntry()
1074 return DE->getLastContent(); in lookupOrCreateEntry()
1079 StringRef Name = SrcE->getName(); in uniqueOverlayTree()
1080 switch (SrcE->getKind()) { in uniqueOverlayTree()
1090 llvm::make_range(DE->contents_begin(), DE->contents_end())) in uniqueOverlayTree()
1099 DE->addContent(llvm::make_unique<RedirectingFileEntry>( in uniqueOverlayTree()
1100 Name, FE->getExternalContentsPath(), FE->getUseName())); in uniqueOverlayTree()
1116 KeyStatusPair("contents", false), in parseEntry()
1117 KeyStatusPair("external-contents", false), in parseEntry()
1118 KeyStatusPair("use-external-name", false), in parseEntry()
1123 bool HasContents = false; // external or otherwise in parseEntry()
1130 for (yaml::MappingNode::iterator I = M->begin(), E = M->end(); I != E; in parseEntry()
1136 if (!parseScalarString(I->getKey(), Key, Buffer)) in parseEntry()
1139 if (!checkDuplicateOrUnknownKey(I->getKey(), Key, Keys)) in parseEntry()
1144 if (!parseScalarString(I->getValue(), Value, Buffer)) in parseEntry()
1147 if (FS->UseCanonicalizedPaths) { in parseEntry()
1158 if (!parseScalarString(I->getValue(), Value, Buffer)) in parseEntry()
1165 error(I->getValue(), "unknown value for 'type'"); in parseEntry()
1168 } else if (Key == "contents") { in parseEntry()
1170 error(I->getKey(), in parseEntry()
1171 "entry already has 'contents' or 'external-contents'"); in parseEntry()
1175 yaml::SequenceNode *Contents = in parseEntry() local
1176 dyn_cast<yaml::SequenceNode>(I->getValue()); in parseEntry()
1177 if (!Contents) { in parseEntry()
1179 error(I->getValue(), "expected array"); in parseEntry()
1183 for (yaml::SequenceNode::iterator I = Contents->begin(), in parseEntry()
1184 E = Contents->end(); in parseEntry()
1191 } else if (Key == "external-contents") { in parseEntry()
1193 error(I->getKey(), in parseEntry()
1194 "entry already has 'contents' or 'external-contents'"); in parseEntry()
1198 if (!parseScalarString(I->getValue(), Value, Buffer)) in parseEntry()
1202 if (FS->IsRelativeOverlay) { in parseEntry()
1203 FullPath = FS->getExternalContentsPrefixDir(); in parseEntry()
1205 "External contents prefix directory must exist"); in parseEntry()
1211 if (FS->UseCanonicalizedPaths) { in parseEntry()
1218 } else if (Key == "use-external-name") { in parseEntry()
1220 if (!parseScalarBool(I->getValue(), Val)) in parseEntry()
1234 error(N, "missing key 'contents' or 'external-contents'"); in parseEntry()
1243 error(N, "'use-external-name' is not supported for directories"); in parseEntry()
1252 Trimmed = Trimmed.slice(0, Trimmed.size()-1); in parseEntry()
1301 KeyStatusPair("case-sensitive", false), in parse()
1302 KeyStatusPair("use-external-names", false), in parse()
1303 KeyStatusPair("overlay-relative", false), in parse()
1311 for (yaml::MappingNode::iterator I = Top->begin(), E = Top->end(); I != E; in parse()
1315 if (!parseScalarString(I->getKey(), Key, KeyBuffer)) in parse()
1318 if (!checkDuplicateOrUnknownKey(I->getKey(), Key, Keys)) in parse()
1322 yaml::SequenceNode *Roots = dyn_cast<yaml::SequenceNode>(I->getValue()); in parse()
1324 error(I->getValue(), "expected array"); in parse()
1328 for (yaml::SequenceNode::iterator I = Roots->begin(), E = Roots->end(); in parse()
1338 if (!parseScalarString(I->getValue(), VersionString, Storage)) in parse()
1342 error(I->getValue(), "expected integer"); in parse()
1346 error(I->getValue(), "invalid version number"); in parse()
1350 error(I->getValue(), "version mismatch, expected 0"); in parse()
1353 } else if (Key == "case-sensitive") { in parse()
1354 if (!parseScalarBool(I->getValue(), FS->CaseSensitive)) in parse()
1356 } else if (Key == "overlay-relative") { in parse()
1357 if (!parseScalarBool(I->getValue(), FS->IsRelativeOverlay)) in parse()
1359 } else if (Key == "use-external-names") { in parse()
1360 if (!parseScalarBool(I->getValue(), FS->UseExternalNames)) in parse()
1393 yaml::Stream Stream(Buffer->getMemBufferRef(), SM); in create()
1397 yaml::Node *Root = DI->getRoot(); in create()
1409 // Use the YAML path from -ivfsoverlay to compute the dir to be prefixed in create()
1410 // to each 'external-contents' path. in create()
1413 // -ivfsoverlay dummy.cache/vfs/vfs.yaml in create()
1415 // FS->ExternalContentsPrefixDir => /<absolute_path_to>/dummy.cache/vfs in create()
1421 FS->setExternalContentsPrefixDir(OverlayAbsDir); in create()
1464 !isTraversalComponent(From->getName()) && in lookupPath()
1469 if (Start->equals(".")) in lookupPath()
1473 StringRef FromName = From->getName(); in lookupPath()
1477 if (CaseSensitive ? !Start->equals(FromName) in lookupPath()
1478 : !Start->equals_lower(FromName)) in lookupPath()
1495 llvm::make_range(DE->contents_begin(), DE->contents_end())) { in lookupPath()
1515 ErrorOr<Status> S = ExternalFS->status(F->getExternalContentsPath()); in status()
1516 assert(!S || S->getName() == F->getExternalContentsPath()); in status()
1518 return getRedirectedFileStatus(Path, F->useExternalName(UseExternalNames), in status()
1523 return Status::copyWithNewName(DE->getStatus(), Path.str()); in status()
1548 return InnerFile->getBuffer(Name, FileSize, RequiresNullTerminator, in getBuffer()
1551 std::error_code close() override { return InnerFile->close(); } in close()
1565 auto Result = ExternalFS->openFileForRead(F->getExternalContentsPath()); in openFileForRead()
1569 auto ExternalStatus = (*Result)->status(); in openFileForRead()
1574 Status S = getRedirectedFileStatus(Path, F->useExternalName(UseExternalNames), in openFileForRead()
1653 OS.indent(Indent + 2) << "'contents': [\n"; in startDirectory()
1669 OS.indent(Indent + 2) << "'external-contents': \"" in writeEntry()
1684 OS << " 'case-sensitive': '" in write()
1687 OS << " 'use-external-names': '" in write()
1692 OS << " 'overlay-relative': '" in write()
1761 llvm::sys::path::append(PathStr, (*Current)->getName()); in VFSFromYamlDirIterImpl()
1774 llvm::sys::path::append(PathStr, (*Current)->getName()); in increment()
1789 directory_iterator I = FS->dir_begin(Path, EC); in recursive_directory_iterator()
1792 State->push(I); in recursive_directory_iterator()
1798 assert(FS && State && !State->empty() && "incrementing past end"); in increment()
1799 assert(State->top()->isStatusKnown() && "non-canonical end iterator"); in increment()
1801 if (State->top()->isDirectory()) { in increment()
1802 vfs::directory_iterator I = FS->dir_begin(State->top()->getName(), EC); in increment()
1806 State->push(I); in increment()
1811 while (!State->empty() && State->top().increment(EC) == End) in increment()
1812 State->pop(); in increment()
1814 if (State->empty()) in increment()