Lines Matching +full:external +full:- +full:contents
1 //===- VirtualFileSystem.cpp - Virtual File System Layer --------*- C++ -*-===//
8 //===----------------------------------------------------------------------===//
10 //===----------------------------------------------------------------------===//
23 #include "llvm/Config/llvm-config.h"
98 return (*F)->getBuffer(Name, FileSize, RequiresNullTerminator, IsVolatile); in getBufferForFile()
111 return Status && Status->exists(); in exists()
114 //===-----------------------------------------------------------------------===/
116 //===-----------------------------------------------------------------------===/
143 assert(FD != -1 && "cannot stat closed file"); in status()
156 assert(FD != -1 && "cannot get buffer for closed file"); in getBuffer()
174 FD = -1; in close()
242 EC = Iter->status(S); in RealFSDirIter()
244 CurrentEntry = Status::copyWithNewName(S, Iter->path()); in RealFSDirIter()
257 EC = Iter->status(S); in increment()
258 CurrentEntry = Status::copyWithNewName(S, Iter->path()); in increment()
270 //===-----------------------------------------------------------------------===/
272 //===-----------------------------------------------------------------------===/
281 FS->setCurrentWorkingDirectory(getCurrentWorkingDirectory().get()); in pushOverlay()
287 ErrorOr<Status> Status = (*I)->status(Path); in status()
298 auto Result = (*I)->openFileForRead(Path); in openFileForRead()
308 return FSList.front()->getCurrentWorkingDirectory(); in getCurrentWorkingDirectory()
313 if (std::error_code EC = FS->setCurrentWorkingDirectory(Path)) in setCurrentWorkingDirectory()
333 CurrentDirIter = (*CurrentFS)->dir_begin(Path, EC); in incrementFS()
372 CurrentDirIter = (*CurrentFS)->dir_begin(Path, EC); in OverlayFSDirIterImpl()
420 return N->getKind() == IME_File; in classof()
437 Buf->getBuffer(), Buf->getBufferIdentifier(), RequiresNullTerminator); in getBuffer()
452 return I->second.get(); in getChild()
457 .first->second.get(); in addChild()
468 Result += Entry.second->toString(Indent + 2); in toString()
473 return N->getKind() == IME_Directory; in classof()
488 return Root->toString(/*Indent=*/0); in toString()
511 detail::InMemoryNode *Node = Dir->getChild(Name); in addFile()
519 Buffer->getBufferSize(), in addFile()
522 Dir->addChild(Name, llvm::make_unique<detail::InMemoryFile>( in addFile()
530 StringRef(Path.str().begin(), Name.end() - Path.str().begin()), in addFile()
532 0, 0, Buffer->getBufferSize(), in addFile()
534 Dir = cast<detail::InMemoryDirectory>(Dir->addChild( in addFile()
550 return cast<detail::InMemoryFile>(Node)->getBuffer()->getBuffer() == in addFile()
551 Buffer->getBuffer(); in addFile()
560 Buffer->getBuffer(), Buffer->getBufferIdentifier())); in addFileNoOwn()
582 detail::InMemoryNode *Node = Dir->getChild(*I); in lookupInMemoryNode()
604 return (*Node)->getStatus(); in status()
614 // When we have a file provide a heap-allocated wrapper for the memory buffer in openFileForRead()
634 CurrentEntry = I->second->getStatus(); in InMemoryDirIterator()
641 CurrentEntry = I != E ? I->second->getStatus() : Status(); in increment()
664 //===-----------------------------------------------------------------------===/
666 //===-----------------------------------------------------------------------===/
688 std::vector<std::unique_ptr<Entry>> Contents; member in __anon450132a50711::RedirectingDirectoryEntry
693 std::vector<std::unique_ptr<Entry>> Contents, in RedirectingDirectoryEntry() argument
695 : Entry(EK_Directory, Name), Contents(std::move(Contents)), in RedirectingDirectoryEntry()
698 typedef decltype(Contents)::iterator iterator;
699 iterator contents_begin() { return Contents.begin(); } in contents_begin()
700 iterator contents_end() { return Contents.end(); } in contents_end()
701 static bool classof(const Entry *E) { return E->getKind() == EK_Directory; } in classof()
720 /// \brief whether to use the external path as the name for this file.
725 static bool classof(const Entry *E) { return E->getKind() == EK_File; } in classof()
746 /// virtual file paths to existing external files, available in \c ExternalFS.
760 /// 'case-sensitive': <boolean, default=true>
761 /// 'use-external-names': <boolean, default=true>
768 /// 'contents': [ <file or directory entries> ]
781 /// Re-mapped files are represented as
786 /// 'use-external-name': <boolean> # Optional
787 /// 'external-contents': <path to external file>)
791 /// and inherit their attributes from the external contents.
799 /// \brief The file system to use for external references.
805 /// \brief Whether to perform case-sensitive comparisons.
807 /// Currently, case-insensitive matching only works correctly with ASCII.
810 /// \brief Whether to use to use the value of 'external-contents' for the
811 /// names of files. This global value is overridable on a per-file basis.
825 /// recursing into the contents of \p From if it is a directory.
834 /// returns a virtual file system representing its contents.
844 return ExternalFS->getCurrentWorkingDirectory(); in getCurrentWorkingDirectory()
847 return ExternalFS->setCurrentWorkingDirectory(Path); in setCurrentWorkingDirectory()
861 if (!S->isDirectory()) { in dir_begin()
869 *this, D->contents_begin(), D->contents_end(), EC)); in dir_begin()
889 Result = S->getValue(Storage); in parseScalarString()
942 if (I->second.Required && !I->second.Seen) { in checkMissingKeys()
943 error(Obj, Twine("missing key '") + I->first + "'"); in checkMissingKeys()
960 KeyStatusPair("contents", false), in parseEntry()
961 KeyStatusPair("external-contents", false), in parseEntry()
962 KeyStatusPair("use-external-name", false), in parseEntry()
967 bool HasContents = false; // external or otherwise in parseEntry()
974 for (yaml::MappingNode::iterator I = M->begin(), E = M->end(); I != E; in parseEntry()
980 if (!parseScalarString(I->getKey(), Key, Buffer)) in parseEntry()
983 if (!checkDuplicateOrUnknownKey(I->getKey(), Key, Keys)) in parseEntry()
988 if (!parseScalarString(I->getValue(), Value, Buffer)) in parseEntry()
992 if (!parseScalarString(I->getValue(), Value, Buffer)) in parseEntry()
999 error(I->getValue(), "unknown value for 'type'"); in parseEntry()
1002 } else if (Key == "contents") { in parseEntry()
1004 error(I->getKey(), in parseEntry()
1005 "entry already has 'contents' or 'external-contents'"); in parseEntry()
1009 yaml::SequenceNode *Contents = in parseEntry() local
1010 dyn_cast<yaml::SequenceNode>(I->getValue()); in parseEntry()
1011 if (!Contents) { in parseEntry()
1013 error(I->getValue(), "expected array"); in parseEntry()
1017 for (yaml::SequenceNode::iterator I = Contents->begin(), in parseEntry()
1018 E = Contents->end(); in parseEntry()
1025 } else if (Key == "external-contents") { in parseEntry()
1027 error(I->getKey(), in parseEntry()
1028 "entry already has 'contents' or 'external-contents'"); in parseEntry()
1032 if (!parseScalarString(I->getValue(), Value, Buffer)) in parseEntry()
1035 } else if (Key == "use-external-name") { in parseEntry()
1037 if (!parseScalarBool(I->getValue(), Val)) in parseEntry()
1051 error(N, "missing key 'contents' or 'external-contents'"); in parseEntry()
1060 error(N, "'use-external-name' is not supported for directories"); in parseEntry()
1069 Trimmed = Trimmed.slice(0, Trimmed.size()-1); in parseEntry()
1118 KeyStatusPair("case-sensitive", false), in parse()
1119 KeyStatusPair("use-external-names", false), in parse()
1126 for (yaml::MappingNode::iterator I = Top->begin(), E = Top->end(); I != E; in parse()
1130 if (!parseScalarString(I->getKey(), Key, KeyBuffer)) in parse()
1133 if (!checkDuplicateOrUnknownKey(I->getKey(), Key, Keys)) in parse()
1137 yaml::SequenceNode *Roots = dyn_cast<yaml::SequenceNode>(I->getValue()); in parse()
1139 error(I->getValue(), "expected array"); in parse()
1143 for (yaml::SequenceNode::iterator I = Roots->begin(), E = Roots->end(); in parse()
1146 FS->Roots.push_back(std::move(E)); in parse()
1153 if (!parseScalarString(I->getValue(), VersionString, Storage)) in parse()
1157 error(I->getValue(), "expected integer"); in parse()
1161 error(I->getValue(), "invalid version number"); in parse()
1165 error(I->getValue(), "version mismatch, expected 0"); in parse()
1168 } else if (Key == "case-sensitive") { in parse()
1169 if (!parseScalarBool(I->getValue(), FS->CaseSensitive)) in parse()
1171 } else if (Key == "use-external-names") { in parse()
1172 if (!parseScalarBool(I->getValue(), FS->UseExternalNames)) in parse()
1196 yaml::Stream Stream(Buffer->getMemBufferRef(), SM); in create()
1200 yaml::Node *Root = DI->getRoot(); in create()
1240 if (Start->equals(".")) in lookupPath()
1244 if (CaseSensitive ? !Start->equals(From->getName()) in lookupPath()
1245 : !Start->equals_lower(From->getName())) in lookupPath()
1261 llvm::make_range(DE->contents_begin(), DE->contents_end())) { in lookupPath()
1281 ErrorOr<Status> S = ExternalFS->status(F->getExternalContentsPath()); in status()
1282 assert(!S || S->getName() == F->getExternalContentsPath()); in status()
1284 return getRedirectedFileStatus(Path, F->useExternalName(UseExternalNames), in status()
1289 return Status::copyWithNewName(DE->getStatus(), Path.str()); in status()
1314 return InnerFile->getBuffer(Name, FileSize, RequiresNullTerminator, in getBuffer()
1317 std::error_code close() override { return InnerFile->close(); } in close()
1331 auto Result = ExternalFS->openFileForRead(F->getExternalContentsPath()); in openFileForRead()
1335 auto ExternalStatus = (*Result)->status(); in openFileForRead()
1340 Status S = getRedirectedFileStatus(Path, F->useExternalName(UseExternalNames), in openFileForRead()
1424 OS.indent(Indent + 2) << "'contents': [\n"; in startDirectory()
1440 OS.indent(Indent + 2) << "'external-contents': \"" in writeEntry()
1452 OS << " 'case-sensitive': '" in write()
1503 llvm::sys::path::append(PathStr, (*Current)->getName()); in VFSFromYamlDirIterImpl()
1516 llvm::sys::path::append(PathStr, (*Current)->getName()); in increment()
1531 directory_iterator I = FS->dir_begin(Path, EC); in recursive_directory_iterator()
1534 State->push(I); in recursive_directory_iterator()
1540 assert(FS && State && !State->empty() && "incrementing past end"); in increment()
1541 assert(State->top()->isStatusKnown() && "non-canonical end iterator"); in increment()
1543 if (State->top()->isDirectory()) { in increment()
1544 vfs::directory_iterator I = FS->dir_begin(State->top()->getName(), EC); in increment()
1548 State->push(I); in increment()
1553 while (!State->empty() && State->top().increment(EC) == End) in increment()
1554 State->pop(); in increment()
1556 if (State->empty()) in increment()