Ninja
Public Types | Public Member Functions | List of all members
RealDiskInterface Struct Reference

Implementation of DiskInterface that actually hits the disk. More...

#include <disk_interface.h>

Inheritance diagram for RealDiskInterface:
Inheritance graph
[legend]

Public Types

enum  Status { Okay , NotFound , OtherError }
 Result of ReadFile. More...
 

Public Member Functions

void AllowStatCache (bool allow)
 Whether stat information can be cached. Only has an effect on Windows. More...
 
bool MakeDir (const std::string &path) override
 Create a directory, returning false on failure. More...
 
bool MakeDirs (const std::string &path)
 Create all the parent directories for path; like mkdir -p basename path. More...
 
Status ReadFile (const std::string &path, std::string *contents, std::string *err) override
 Read and store in given string. More...
 
 RealDiskInterface ()
 
int RemoveFile (const std::string &path) override
 Remove the file named path. More...
 
TimeStamp Stat (const std::string &path, std::string *err) const override
 stat() a file, returning the mtime, or 0 if missing and -1 on other errors. More...
 
bool WriteFile (const std::string &path, const std::string &contents, bool crlf_on_windows) override
 Create a file, with the specified name and contents If crlf_on_windows is true,
will be converted to \r
(only on Windows builds of Ninja). More...
 
virtual ~RealDiskInterface ()
 

Detailed Description

Implementation of DiskInterface that actually hits the disk.

Definition at line 73 of file disk_interface.h.

Member Enumeration Documentation

◆ Status

enum FileReader::Status
inherited

Result of ReadFile.

Enumerator
Okay 
NotFound 
OtherError 

Definition at line 29 of file disk_interface.h.

Constructor & Destructor Documentation

◆ RealDiskInterface()

RealDiskInterface::RealDiskInterface ( )

Definition at line 161 of file disk_interface.cc.

◆ ~RealDiskInterface()

virtual RealDiskInterface::~RealDiskInterface ( )
inlinevirtual

Definition at line 75 of file disk_interface.h.

Member Function Documentation

◆ AllowStatCache()

void RealDiskInterface::AllowStatCache ( bool  allow)

Whether stat information can be cached. Only has an effect on Windows.

Definition at line 355 of file disk_interface.cc.

◆ MakeDir()

bool RealDiskInterface::MakeDir ( const std::string &  path)
overridevirtual

Create a directory, returning false on failure.

Implements DiskInterface.

Definition at line 279 of file disk_interface.cc.

References Error().

◆ MakeDirs()

bool DiskInterface::MakeDirs ( const std::string &  path)
inherited

Create all the parent directories for path; like mkdir -p basename path.

Definition at line 140 of file disk_interface.cc.

References Error().

Referenced by Builder::StartEdge().

◆ ReadFile()

FileReader::Status RealDiskInterface::ReadFile ( const std::string &  path,
std::string *  contents,
std::string *  err 
)
overridevirtual

Read and store in given string.

On success, return Okay. On error, return another Status and fill |err|.

Implements FileReader.

Definition at line 290 of file disk_interface.cc.

References ReadFile().

◆ RemoveFile()

int RealDiskInterface::RemoveFile ( const std::string &  path)
overridevirtual

Remove the file named path.

It behaves like 'rm -f path' so no errors are reported if it does not exists.

Returns
0 if the file has been removed, 1 if the file does not exist, and -1 if an error occurs.

Implements DiskInterface.

Definition at line 300 of file disk_interface.cc.

References Error().

◆ Stat()

TimeStamp RealDiskInterface::Stat ( const std::string &  path,
std::string *  err 
) const
overridevirtual

stat() a file, returning the mtime, or 0 if missing and -1 on other errors.

Implements DiskInterface.

Definition at line 179 of file disk_interface.cc.

References METRIC_RECORD.

Referenced by WriteFakeManifests().

◆ WriteFile()

bool RealDiskInterface::WriteFile ( const std::string &  path,
const std::string &  contents,
bool  crlf_on_windows 
)
overridevirtual

Create a file, with the specified name and contents If crlf_on_windows is true,
will be converted to \r
(only on Windows builds of Ninja).

Returns true on success, false on failure

Implements DiskInterface.

Definition at line 248 of file disk_interface.cc.

References Error().


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