Lines Matching +full:external +full:- +full:contents

1 //===- VirtualFileSystem.cpp - Virtual File System Layer --------*- C++ -*-===//
8 //===----------------------------------------------------------------------===//
10 //===----------------------------------------------------------------------===//
79 return (*F)->getBuffer(Name, FileSize, RequiresNullTerminator, IsVolatile); in getBufferForFile()
82 //===-----------------------------------------------------------------------===/
84 //===-----------------------------------------------------------------------===/
100 getBuffer(const Twine &Name, int64_t FileSize = -1,
110 assert(FD != -1 && "cannot stat closed file"); in status()
125 assert(FD != -1 && "cannot get buffer for closed file"); in getBuffer()
143 FD = -1; in close()
176 Result->setName(Name.str()); in openFileForRead()
194 EC = Iter->status(S); in RealFSDirIter()
197 CurrentEntry.setName(Iter->path()); in RealFSDirIter()
211 EC = Iter->status(S); in increment()
213 CurrentEntry.setName(Iter->path()); in increment()
225 //===-----------------------------------------------------------------------===/
227 //===-----------------------------------------------------------------------===/
239 ErrorOr<Status> Status = (*I)->status(Path); in status()
250 auto Result = (*I)->openFileForRead(Path); in openFileForRead()
272 CurrentDirIter = (*CurrentFS)->dir_begin(Path, EC); in incrementFS()
311 CurrentDirIter = (*CurrentFS)->dir_begin(Path, EC); in OverlayFSDirIterImpl()
325 //===-----------------------------------------------------------------------===/
327 //===-----------------------------------------------------------------------===/
363 std::vector<Entry *> Contents; member in __anonfd6d57aa0511::DirectoryEntry
368 DirectoryEntry(StringRef Name, std::vector<Entry *> Contents, Status S) in DirectoryEntry() argument
369 : Entry(EK_Directory, Name), Contents(std::move(Contents)), in DirectoryEntry()
373 iterator contents_begin() { return Contents.begin(); } in contents_begin()
374 iterator contents_end() { return Contents.end(); } in contents_end()
375 static bool classof(const Entry *E) { return E->getKind() == EK_Directory; } in classof()
393 /// \brief whether to use the external path as the name for this file.
398 static bool classof(const Entry *E) { return E->getKind() == EK_File; } in classof()
417 /// virtual file paths to existing external files, available in \c ExternalFS.
431 /// 'case-sensitive': <boolean, default=true>
432 /// 'use-external-names': <boolean, default=true>
439 /// 'contents': [ <file or directory entries> ]
452 /// Re-mapped files are represented as
457 /// 'use-external-name': <boolean> # Optional
458 /// 'external-contents': <path to external file>)
462 /// and inherit their attributes from the external contents.
469 /// \brief The file system to use for external references.
475 /// \brief Whether to perform case-sensitive comparisons.
477 /// Currently, case-insensitive matching only works correctly with ASCII.
480 /// \brief Whether to use to use the value of 'external-contents' for the
481 /// names of files. This global value is overridable on a per-file basis.
495 /// recursing into the contents of \p From if it is a directory.
506 /// returns a virtual file system representing its contents.
526 if (!S->isDirectory()) { in dir_begin()
534 *this, D->contents_begin(), D->contents_end(), EC)); in dir_begin()
554 Result = S->getValue(Storage); in parseScalarString()
607 if (I->second.Required && !I->second.Seen) { in checkMissingKeys()
608 error(Obj, Twine("missing key '") + I->first + "'"); in checkMissingKeys()
625 KeyStatusPair("contents", false), in parseEntry()
626 KeyStatusPair("external-contents", false), in parseEntry()
627 KeyStatusPair("use-external-name", false), in parseEntry()
633 bool HasContents = false; // external or otherwise in parseEntry()
640 for (yaml::MappingNode::iterator I = M->begin(), E = M->end(); I != E; in parseEntry()
646 if (!parseScalarString(I->getKey(), Key, Buffer)) in parseEntry()
649 if (!checkDuplicateOrUnknownKey(I->getKey(), Key, Keys)) in parseEntry()
654 if (!parseScalarString(I->getValue(), Value, Buffer)) in parseEntry()
658 if (!parseScalarString(I->getValue(), Value, Buffer)) in parseEntry()
665 error(I->getValue(), "unknown value for 'type'"); in parseEntry()
668 } else if (Key == "contents") { in parseEntry()
670 error(I->getKey(), in parseEntry()
671 "entry already has 'contents' or 'external-contents'"); in parseEntry()
675 yaml::SequenceNode *Contents = in parseEntry() local
676 dyn_cast<yaml::SequenceNode>(I->getValue()); in parseEntry()
677 if (!Contents) { in parseEntry()
679 error(I->getValue(), "expected array"); in parseEntry()
683 for (yaml::SequenceNode::iterator I = Contents->begin(), in parseEntry()
684 E = Contents->end(); in parseEntry()
691 } else if (Key == "external-contents") { in parseEntry()
693 error(I->getKey(), in parseEntry()
694 "entry already has 'contents' or 'external-contents'"); in parseEntry()
698 if (!parseScalarString(I->getValue(), Value, Buffer)) in parseEntry()
701 } else if (Key == "use-external-name") { in parseEntry()
703 if (!parseScalarBool(I->getValue(), Val)) in parseEntry()
716 error(N, "missing key 'contents' or 'external-contents'"); in parseEntry()
724 error(N, "'use-external-name' is not supported for directories"); in parseEntry()
733 Trimmed = Trimmed.slice(0, Trimmed.size()-1); in parseEntry()
778 KeyStatusPair("case-sensitive", false), in parse()
779 KeyStatusPair("use-external-names", false), in parse()
787 for (yaml::MappingNode::iterator I = Top->begin(), E = Top->end(); I != E; in parse()
791 if (!parseScalarString(I->getKey(), Key, KeyBuffer)) in parse()
794 if (!checkDuplicateOrUnknownKey(I->getKey(), Key, Keys)) in parse()
798 yaml::SequenceNode *Roots = dyn_cast<yaml::SequenceNode>(I->getValue()); in parse()
800 error(I->getValue(), "expected array"); in parse()
804 for (yaml::SequenceNode::iterator I = Roots->begin(), E = Roots->end(); in parse()
807 FS->Roots.push_back(E); in parse()
814 if (!parseScalarString(I->getValue(), VersionString, Storage)) in parse()
818 error(I->getValue(), "expected integer"); in parse()
822 error(I->getValue(), "invalid version number"); in parse()
826 error(I->getValue(), "version mismatch, expected 0"); in parse()
829 } else if (Key == "case-sensitive") { in parse()
830 if (!parseScalarBool(I->getValue(), FS->CaseSensitive)) in parse()
832 } else if (Key == "use-external-names") { in parse()
833 if (!parseScalarBool(I->getValue(), FS->UseExternalNames)) in parse()
851 DirectoryEntry::~DirectoryEntry() { llvm::DeleteContainerPointers(Contents); } in ~DirectoryEntry()
861 yaml::Stream Stream(Buffer->getMemBufferRef(), SM); in create()
865 yaml::Node *Root = DI->getRoot(); in create()
905 if (Start->equals(".")) in lookupPath()
909 if (CaseSensitive ? !Start->equals(From->getName()) in lookupPath()
910 : !Start->equals_lower(From->getName())) in lookupPath()
925 for (DirectoryEntry::iterator I = DE->contents_begin(), in lookupPath()
926 E = DE->contents_end(); in lookupPath()
939 ErrorOr<Status> S = ExternalFS->status(F->getExternalContentsPath()); in status()
940 assert(!S || S->getName() == F->getExternalContentsPath()); in status()
941 if (S && !F->useExternalName(UseExternalNames)) in status()
942 S->setName(PathStr); in status()
944 S->IsVFSMapped = true; in status()
948 Status S = DE->getStatus(); in status()
970 auto Result = ExternalFS->openFileForRead(F->getExternalContentsPath()); in openFileForRead()
974 if (!F->useExternalName(UseExternalNames)) in openFileForRead()
975 (*Result)->setName(Path.str()); in openFileForRead()
1062 OS.indent(Indent + 2) << "'contents': [\n"; in startDirectory()
1078 OS.indent(Indent + 2) << "'external-contents': \"" in writeEntry()
1090 OS << " 'case-sensitive': '" in write()
1142 llvm::sys::path::append(PathStr, (*Current)->getName()); in VFSFromYamlDirIterImpl()
1155 llvm::sys::path::append(PathStr, (*Current)->getName()); in increment()
1170 directory_iterator I = FS->dir_begin(Path, EC); in recursive_directory_iterator()
1173 State->push(I); in recursive_directory_iterator()
1179 assert(FS && State && !State->empty() && "incrementing past end"); in increment()
1180 assert(State->top()->isStatusKnown() && "non-canonical end iterator"); in increment()
1182 if (State->top()->isDirectory()) { in increment()
1183 vfs::directory_iterator I = FS->dir_begin(State->top()->getName(), EC); in increment()
1187 State->push(I); in increment()
1192 while (!State->empty() && State->top().increment(EC) == End) in increment()
1193 State->pop(); in increment()
1195 if (State->empty()) in increment()