LLVM 18.0.0git
|
A file system that allows overlaying one AbstractFileSystem
on top of another.
More...
#include "llvm/Support/VirtualFileSystem.h"
Public Types | |
using | iterator = FileSystemList::reverse_iterator |
using | const_iterator = FileSystemList::const_reverse_iterator |
using | reverse_iterator = FileSystemList::iterator |
using | const_reverse_iterator = FileSystemList::const_iterator |
using | range = iterator_range< iterator > |
using | const_range = iterator_range< const_iterator > |
![]() | |
enum class | PrintType { Summary , Contents , RecursiveContents } |
Public Member Functions | |
OverlayFileSystem (IntrusiveRefCntPtr< FileSystem > Base) | |
void | pushOverlay (IntrusiveRefCntPtr< FileSystem > FS) |
Pushes a file system on top of the stack. | |
llvm::ErrorOr< Status > | status (const Twine &Path) override |
Get the status of the entry at Path , if one exists. | |
llvm::ErrorOr< std::unique_ptr< File > > | openFileForRead (const Twine &Path) override |
Get a File object for the file at Path , if one exists. | |
directory_iterator | dir_begin (const Twine &Dir, std::error_code &EC) override |
Get a directory_iterator for Dir . | |
llvm::ErrorOr< std::string > | getCurrentWorkingDirectory () const override |
Get the working directory of this file system. | |
std::error_code | setCurrentWorkingDirectory (const Twine &Path) override |
Set the working directory. | |
std::error_code | isLocal (const Twine &Path, bool &Result) override |
Is the file mounted on a local filesystem? | |
std::error_code | getRealPath (const Twine &Path, SmallVectorImpl< char > &Output) const override |
Gets real path of Path e.g. | |
iterator | overlays_begin () |
Get an iterator pointing to the most recently added file system. | |
const_iterator | overlays_begin () const |
iterator | overlays_end () |
Get an iterator pointing one-past the least recently added file system. | |
const_iterator | overlays_end () const |
reverse_iterator | overlays_rbegin () |
Get an iterator pointing to the least recently added file system. | |
const_reverse_iterator | overlays_rbegin () const |
reverse_iterator | overlays_rend () |
Get an iterator pointing one-past the most recently added file system. | |
const_reverse_iterator | overlays_rend () const |
range | overlays_range () |
const_range | overlays_range () const |
![]() | |
virtual | ~FileSystem () |
virtual llvm::ErrorOr< Status > | status (const Twine &Path)=0 |
Get the status of the entry at Path , if one exists. | |
virtual llvm::ErrorOr< std::unique_ptr< File > > | openFileForRead (const Twine &Path)=0 |
Get a File object for the file at Path , if one exists. | |
llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > | getBufferForFile (const Twine &Name, int64_t FileSize=-1, bool RequiresNullTerminator=true, bool IsVolatile=false) |
This is a convenience method that opens a file, gets its content and then closes the file. | |
virtual directory_iterator | dir_begin (const Twine &Dir, std::error_code &EC)=0 |
Get a directory_iterator for Dir . | |
virtual std::error_code | setCurrentWorkingDirectory (const Twine &Path)=0 |
Set the working directory. | |
virtual llvm::ErrorOr< std::string > | getCurrentWorkingDirectory () const =0 |
Get the working directory of this file system. | |
virtual std::error_code | getRealPath (const Twine &Path, SmallVectorImpl< char > &Output) const |
Gets real path of Path e.g. | |
bool | exists (const Twine &Path) |
Check whether a file exists. Provided for convenience. | |
virtual std::error_code | isLocal (const Twine &Path, bool &Result) |
Is the file mounted on a local filesystem? | |
virtual std::error_code | makeAbsolute (SmallVectorImpl< char > &Path) const |
Make Path an absolute path. | |
void | print (raw_ostream &OS, PrintType Type=PrintType::Contents, unsigned IndentLevel=0) const |
LLVM_DUMP_METHOD void | dump () const |
![]() | |
unsigned | UseCount () const |
void | Retain () const |
void | Release () const |
Protected Member Functions | |
void | printImpl (raw_ostream &OS, PrintType Type, unsigned IndentLevel) const override |
![]() | |
virtual void | printImpl (raw_ostream &OS, PrintType Type, unsigned IndentLevel) const |
void | printIndent (raw_ostream &OS, unsigned IndentLevel) const |
![]() | |
ThreadSafeRefCountedBase ()=default | |
ThreadSafeRefCountedBase (const ThreadSafeRefCountedBase &) | |
ThreadSafeRefCountedBase & | operator= (const ThreadSafeRefCountedBase &)=delete |
~ThreadSafeRefCountedBase () | |
A file system that allows overlaying one AbstractFileSystem
on top of another.
Consists of a stack of >=1 FileSystem
objects, which are treated as being one merged file system. When there is a directory that exists in more than one file system, the OverlayFileSystem
contains a directory containing the union of their contents. The attributes (permissions, etc.) of the top-most (most recently added) directory are used. When there is a file that exists in more than one file system, the file in the top-most file system overrides the other(s).
Definition at line 366 of file VirtualFileSystem.h.
Definition at line 390 of file VirtualFileSystem.h.
Definition at line 394 of file VirtualFileSystem.h.
Definition at line 392 of file VirtualFileSystem.h.
Definition at line 389 of file VirtualFileSystem.h.
Definition at line 393 of file VirtualFileSystem.h.
Definition at line 391 of file VirtualFileSystem.h.
OverlayFileSystem::OverlayFileSystem | ( | IntrusiveRefCntPtr< FileSystem > | Base | ) |
Definition at line 421 of file VirtualFileSystem.cpp.
References llvm::SmallVectorTemplateBase< T, bool >::push_back().
|
overridevirtual |
Get a directory_iterator for Dir
.
Implements llvm::vfs::FileSystem.
Definition at line 579 of file VirtualFileSystem.cpp.
References llvm::Twine::str().
|
overridevirtual |
Get the working directory of this file system.
Implements llvm::vfs::FileSystem.
Definition at line 454 of file VirtualFileSystem.cpp.
References llvm::SmallVectorTemplateCommon< T, typename >::front().
Referenced by pushOverlay().
|
overridevirtual |
Gets real path of Path
e.g.
collapse all . and .. patterns, resolve symlinks. For real file system, this uses llvm::sys::fs::real_path
. This returns errc::operation_not_permitted if not implemented by subclass.
Reimplemented from llvm::vfs::FileSystem.
Definition at line 475 of file VirtualFileSystem.cpp.
References llvm::no_such_file_or_directory.
Is the file mounted on a local filesystem?
Reimplemented from llvm::vfs::FileSystem.
Definition at line 467 of file VirtualFileSystem.cpp.
References llvm::no_such_file_or_directory.
|
overridevirtual |
Get a File
object for the file at Path
, if one exists.
Implements llvm::vfs::FileSystem.
Definition at line 443 of file VirtualFileSystem.cpp.
References E, I, llvm::make_error_code(), llvm::no_such_file_or_directory, overlays_begin(), and overlays_end().
|
inline |
Get an iterator pointing to the most recently added file system.
Definition at line 397 of file VirtualFileSystem.h.
References llvm::SmallVectorTemplateCommon< T, typename >::rbegin().
Referenced by openFileForRead(), and status().
|
inline |
Definition at line 398 of file VirtualFileSystem.h.
References llvm::SmallVectorTemplateCommon< T, typename >::rbegin().
|
inline |
Get an iterator pointing one-past the least recently added file system.
Definition at line 401 of file VirtualFileSystem.h.
References llvm::SmallVectorTemplateCommon< T, typename >::rend().
Referenced by openFileForRead(), and status().
|
inline |
Definition at line 402 of file VirtualFileSystem.h.
References llvm::SmallVectorTemplateCommon< T, typename >::rend().
|
inline |
Definition at line 412 of file VirtualFileSystem.h.
References llvm::reverse().
Referenced by printImpl().
|
inline |
Definition at line 413 of file VirtualFileSystem.h.
References llvm::reverse().
|
inline |
Get an iterator pointing to the least recently added file system.
Definition at line 405 of file VirtualFileSystem.h.
References llvm::SmallVectorTemplateCommon< T, typename >::begin().
|
inline |
Definition at line 406 of file VirtualFileSystem.h.
References llvm::SmallVectorTemplateCommon< T, typename >::begin().
|
inline |
Get an iterator pointing one-past the most recently added file system.
Definition at line 409 of file VirtualFileSystem.h.
References llvm::SmallVectorTemplateCommon< T, typename >::end().
|
inline |
Definition at line 410 of file VirtualFileSystem.h.
References llvm::SmallVectorTemplateCommon< T, typename >::end().
|
overrideprotectedvirtual |
Reimplemented from llvm::vfs::FileSystem.
Definition at line 483 of file VirtualFileSystem.cpp.
References llvm::vfs::FileSystem::Contents, OS, overlays_range(), llvm::vfs::FileSystem::printIndent(), and llvm::vfs::FileSystem::Summary.
void OverlayFileSystem::pushOverlay | ( | IntrusiveRefCntPtr< FileSystem > | FS | ) |
Pushes a file system on top of the stack.
Definition at line 425 of file VirtualFileSystem.cpp.
References llvm::get(), getCurrentWorkingDirectory(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Set the working directory.
This will affect all following operations on this file system and may propagate down for nested file systems.
Implements llvm::vfs::FileSystem.
Definition at line 460 of file VirtualFileSystem.cpp.
Get the status of the entry at Path
, if one exists.
Implements llvm::vfs::FileSystem.
Definition at line 432 of file VirtualFileSystem.cpp.
References E, I, llvm::make_error_code(), llvm::no_such_file_or_directory, overlays_begin(), and overlays_end().