mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Plumbing for a Virtual File System
Adds the -vfsoverlay frontend option that enables the user to pass VFS overlay YAML files to Swift. These files define a (potentially many-layered) virtual mapping on which we predicate a VFS. Switch all input-based memory buffer reads in the Frontend to the new FileSystem-based approach.
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "swift/Basic/FileSystem.h"
|
||||
#include "llvm/Support/FileSystem.h"
|
||||
#include "llvm/Support/Process.h"
|
||||
#include "clang/Basic/FileManager.h"
|
||||
|
||||
using namespace swift;
|
||||
|
||||
@@ -88,3 +89,18 @@ std::error_code swift::moveFileIfDifferent(const llvm::Twine &source,
|
||||
// If we get here, we weren't able to prove that the files are the same.
|
||||
return fs::rename(source, destination);
|
||||
}
|
||||
|
||||
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
|
||||
swift::vfs::getFileOrSTDIN(clang::vfs::FileSystem &FS,
|
||||
const llvm::Twine &Filename,
|
||||
int64_t FileSize,
|
||||
bool RequiresNullTerminator,
|
||||
bool IsVolatile) {
|
||||
llvm::SmallString<256> NameBuf;
|
||||
llvm::StringRef NameRef = Filename.toStringRef(NameBuf);
|
||||
|
||||
if (NameRef == "-")
|
||||
return llvm::MemoryBuffer::getSTDIN();
|
||||
return FS.getBufferForFile(Filename, FileSize,
|
||||
RequiresNullTerminator, IsVolatile);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user