class FileSystem

Declaration

class FileSystem : public ThreadSafeRefCountedBase { /* full declaration omitted */ };

Description

The virtual file system interface.

Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:268

Inherits from: ThreadSafeRefCountedBase

Method Overview

  • public virtual llvm::vfs::directory_iterator dir_begin(const llvm::Twine & Dir, std::error_code & EC)
  • public void dump() const
  • public bool exists(const llvm::Twine & Path)
  • public llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> getBufferForFile(const llvm::Twine & Name, int64_t FileSize = -1, bool RequiresNullTerminator = true, bool IsVolatile = false)
  • public virtual llvm::ErrorOr<std::string> getCurrentWorkingDirectory() const
  • public virtual std::error_code getRealPath(const llvm::Twine & Path, SmallVectorImpl<char> & Output) const
  • public virtual std::error_code isLocal(const llvm::Twine & Path, bool & Result)
  • public virtual std::error_code makeAbsolute(SmallVectorImpl<char> & Path) const
  • public virtual llvm::ErrorOr<std::unique_ptr<File>> openFileForRead(const llvm::Twine & Path)
  • public void print(llvm::raw_ostream & OS, llvm::vfs::FileSystem::PrintType Type = PrintType::Contents, unsigned int IndentLevel = 0) const
  • protected virtual void printImpl(llvm::raw_ostream & OS, llvm::vfs::FileSystem::PrintType Type, unsigned int IndentLevel) const
  • protected void printIndent(llvm::raw_ostream & OS, unsigned int IndentLevel) const
  • public virtual std::error_code setCurrentWorkingDirectory(const llvm::Twine & Path)
  • public virtual llvm::ErrorOr<Status> status(const llvm::Twine & Path)
  • public virtual ~FileSystem()

Methods

virtual llvm::vfs::directory_iterator dir_begin(
    const llvm::Twine& Dir,
    std::error_code& EC)

Description

Get a directory_iterator for \p Dir.

Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:287

Parameters

const llvm::Twine& Dir
std::error_code& EC

void dump() const

Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:329

bool exists(const llvm::Twine& Path)

Description

Check whether a file exists. Provided for convenience.

Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:304

Parameters

const llvm::Twine& Path

llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
getBufferForFile(
    const llvm::Twine& Name,
    int64_t FileSize = -1,
    bool RequiresNullTerminator = true,
    bool IsVolatile = false)

Description

This is a convenience method that opens a file, gets its content and then closes the file.

Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:282

Parameters

const llvm::Twine& Name
int64_t FileSize = -1
bool RequiresNullTerminator = true
bool IsVolatile = false

virtual llvm::ErrorOr<std::string>
getCurrentWorkingDirectory() const

Description

Get the working directory of this file system.

Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:295

virtual std::error_code getRealPath(
    const llvm::Twine& Path,
    SmallVectorImpl<char>& Output) const

Description

Gets real path of \p 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.

Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:300

Parameters

const llvm::Twine& Path
SmallVectorImpl<char>& Output

virtual std::error_code isLocal(
    const llvm::Twine& Path,
    bool& Result)

Description

Is the file mounted on a local filesystem?

Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:307

Parameters

const llvm::Twine& Path
bool& Result

virtual std::error_code makeAbsolute(
    SmallVectorImpl<char>& Path) const

Description

Make \a Path an absolute path. Makes \a Path absolute using the current directory if it is not already. An empty \a Path will result in the current directory. /absolute/path => /absolute/path relative/../path => <current -directory>/relative/../path

Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:320

Parameters

SmallVectorImpl<char>& Path
A path that is modified to be an absolute path.

Returns

success if \a path has been made absolute, otherwise a platform-specific error_code.

virtual llvm::ErrorOr<std::unique_ptr<File>>
openFileForRead(const llvm::Twine& Path)

Description

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

Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:277

Parameters

const llvm::Twine& Path

void print(llvm::raw_ostream& OS,
           llvm::vfs::FileSystem::PrintType Type =
               PrintType::Contents,
           unsigned int IndentLevel = 0) const

Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:323

Parameters

llvm::raw_ostream& OS
llvm::vfs::FileSystem::PrintType Type = PrintType::Contents
unsigned int IndentLevel = 0

virtual void printImpl(
    llvm::raw_ostream& OS,
    llvm::vfs::FileSystem::PrintType Type,
    unsigned int IndentLevel) const

Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:333

Parameters

llvm::raw_ostream& OS
llvm::vfs::FileSystem::PrintType Type
unsigned int IndentLevel

void printIndent(llvm::raw_ostream& OS,
                 unsigned int IndentLevel) const

Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:339

Parameters

llvm::raw_ostream& OS
unsigned int IndentLevel

virtual std::error_code
setCurrentWorkingDirectory(
    const llvm::Twine& Path)

Description

Set the working directory. This will affect all following operations on this file system and may propagate down for nested file systems.

Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:292

Parameters

const llvm::Twine& Path

virtual llvm::ErrorOr<Status> status(
    const llvm::Twine& Path)

Description

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

Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:273

Parameters

const llvm::Twine& Path

virtual ~FileSystem()

Declared at: llvm/include/llvm/Support/VirtualFileSystem.h:270