LLVM  8.0.1
Public Types | Public Member Functions | List of all members
llvm::vfs::OverlayFileSystem Class Reference

A file system that allows overlaying one AbstractFileSystem on top of another. More...

#include "llvm/Support/VirtualFileSystem.h"

Inheritance diagram for llvm::vfs::OverlayFileSystem:
Inheritance graph
[legend]
Collaboration diagram for llvm::vfs::OverlayFileSystem:
Collaboration graph
[legend]

Public Types

using iterator = FileSystemList::reverse_iterator
 
using const_iterator = FileSystemList::const_reverse_iterator
 

Public Member Functions

 OverlayFileSystem (IntrusiveRefCntPtr< FileSystem > Base)
 
void pushOverlay (IntrusiveRefCntPtr< FileSystem > FS)
 Pushes a file system on top of the stack. More...
 
llvm::ErrorOr< Statusstatus (const Twine &Path) override
 Get the status of the entry at Path, if one exists. More...
 
llvm::ErrorOr< std::unique_ptr< File > > openFileForRead (const Twine &Path) override
 Get a File object for the file at Path, if one exists. More...
 
directory_iterator dir_begin (const Twine &Dir, std::error_code &EC) override
 Get a directory_iterator for Dir. More...
 
llvm::ErrorOr< std::string > getCurrentWorkingDirectory () const override
 Get the working directory of this file system. More...
 
std::error_code setCurrentWorkingDirectory (const Twine &Path) override
 Set the working directory. More...
 
std::error_code isLocal (const Twine &Path, bool &Result) override
 Is the file mounted on a local filesystem? More...
 
std::error_code getRealPath (const Twine &Path, SmallVectorImpl< char > &Output) const override
 Gets real path of Path e.g. More...
 
iterator overlays_begin ()
 Get an iterator pointing to the most recently added file system. More...
 
const_iterator overlays_begin () const
 
iterator overlays_end ()
 Get an iterator pointing one-past the least recently added file system. More...
 
const_iterator overlays_end () const
 
- Public Member Functions inherited from llvm::vfs::FileSystem
virtual ~FileSystem ()
 
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. More...
 
bool exists (const Twine &Path)
 Check whether a file exists. Provided for convenience. More...
 
std::error_code makeAbsolute (SmallVectorImpl< char > &Path) const
 Make Path an absolute path. More...
 
- Public Member Functions inherited from llvm::ThreadSafeRefCountedBase< FileSystem >
void Retain () const
 
void Release () const
 

Additional Inherited Members

- Protected Member Functions inherited from llvm::ThreadSafeRefCountedBase< FileSystem >
 ThreadSafeRefCountedBase ()
 

Detailed Description

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 314 of file VirtualFileSystem.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 338 of file VirtualFileSystem.h.

◆ iterator

Definition at line 337 of file VirtualFileSystem.h.

Constructor & Destructor Documentation

◆ OverlayFileSystem()

OverlayFileSystem::OverlayFileSystem ( IntrusiveRefCntPtr< FileSystem Base)

Definition at line 344 of file VirtualFileSystem.cpp.

Member Function Documentation

◆ dir_begin()

directory_iterator OverlayFileSystem::dir_begin ( const Twine Dir,
std::error_code &  EC 
)
overridevirtual

Get a directory_iterator for Dir.

Note
The 'end' iterator is directory_iterator().

Implements llvm::vfs::FileSystem.

Definition at line 470 of file VirtualFileSystem.cpp.

◆ getCurrentWorkingDirectory()

llvm::ErrorOr< std::string > OverlayFileSystem::getCurrentWorkingDirectory ( ) const
overridevirtual

Get the working directory of this file system.

Implements llvm::vfs::FileSystem.

Definition at line 377 of file VirtualFileSystem.cpp.

◆ getRealPath()

std::error_code OverlayFileSystem::getRealPath ( const Twine Path,
SmallVectorImpl< char > &  Output 
) const
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 398 of file VirtualFileSystem.cpp.

References assert(), E, llvm::sys::path::filename(), llvm::vfs::directory_iterator::increment(), llvm::StringSet< AllocatorTy >::insert(), llvm_unreachable, llvm::no_such_file_or_directory, overlays_begin(), overlays_end(), llvm::Twine::str(), and llvm::vfs::detail::DirIterImpl::~DirIterImpl().

◆ isLocal()

std::error_code OverlayFileSystem::isLocal ( const Twine Path,
bool Result 
)
overridevirtual

Is the file mounted on a local filesystem?

Reimplemented from llvm::vfs::FileSystem.

Definition at line 390 of file VirtualFileSystem.cpp.

References llvm::no_such_file_or_directory.

◆ openFileForRead()

ErrorOr< std::unique_ptr< File > > OverlayFileSystem::openFileForRead ( const Twine Path)
overridevirtual

Get a File object for the file at Path, if one exists.

Implements llvm::vfs::FileSystem.

Definition at line 366 of file VirtualFileSystem.cpp.

References E, I, llvm::make_error_code(), and llvm::no_such_file_or_directory.

◆ overlays_begin() [1/2]

iterator llvm::vfs::OverlayFileSystem::overlays_begin ( )
inline

Get an iterator pointing to the most recently added file system.

Definition at line 341 of file VirtualFileSystem.h.

References llvm::SmallVectorTemplateCommon< T, typename >::rbegin().

Referenced by getRealPath().

◆ overlays_begin() [2/2]

const_iterator llvm::vfs::OverlayFileSystem::overlays_begin ( ) const
inline

◆ overlays_end() [1/2]

iterator llvm::vfs::OverlayFileSystem::overlays_end ( )
inline

Get an iterator pointing one-past the least recently added file system.

Definition at line 346 of file VirtualFileSystem.h.

References llvm::SmallVectorTemplateCommon< T, typename >::rend().

Referenced by getRealPath().

◆ overlays_end() [2/2]

const_iterator llvm::vfs::OverlayFileSystem::overlays_end ( ) const
inline

◆ pushOverlay()

void OverlayFileSystem::pushOverlay ( IntrusiveRefCntPtr< FileSystem FS)

Pushes a file system on top of the stack.

Definition at line 348 of file VirtualFileSystem.cpp.

References llvm::vfs::FileSystem::setCurrentWorkingDirectory().

◆ setCurrentWorkingDirectory()

std::error_code OverlayFileSystem::setCurrentWorkingDirectory ( const Twine Path)
overridevirtual

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 383 of file VirtualFileSystem.cpp.

◆ status()

ErrorOr< Status > OverlayFileSystem::status ( const Twine Path)
overridevirtual

Get the status of the entry at Path, if one exists.

Implements llvm::vfs::FileSystem.

Definition at line 355 of file VirtualFileSystem.cpp.

References E, llvm::ErrorOr< T >::getError(), I, llvm::make_error_code(), and llvm::no_such_file_or_directory.


The documentation for this class was generated from the following files: