Ninja
Functions
util.h File Reference
#include <stdint.h>
#include <string>
Include dependency graph for util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool CanonicalizePath (string *path, string *err)
 Canonicalize a path like "foo/../bar.h" into just "bar.h".
void Error (const char *msg,...)
 Log an error message.
void Fatal (const char *msg,...)
 Log a fatal message and exit.
int64_t GetTimeMillis ()
 Get the current time as relative to some epoch.
int MakeDir (const string &path)
 Create a directory (mode 0777 on Unix).
int ReadFile (const string &path, string *contents, string *err)
 Read a file to a string.
void SetCloseOnExec (int fd)
 Mark a file descriptor to not be inherited on exec()s.
void Warning (const char *msg,...)
 Log a warning message.

Function Documentation

bool CanonicalizePath ( string *  path,
string *  err 
)

Canonicalize a path like "foo/../bar.h" into just "bar.h".

Definition at line 68 of file util.cc.

References Fatal().

Referenced by Edge::LoadDepFile(), ManifestParser::ParseDefaults(), ManifestParser::ParseEdge(), and TEST().

void Error ( const char *  msg,
  ... 
)
void Fatal ( const char *  msg,
  ... 
)

Log a fatal message and exit.

Definition at line 40 of file util.cc.

Referenced by CanonicalizePath(), and main().

int64_t GetTimeMillis ( )

Get the current time as relative to some epoch.

Epoch varies between platforms; only useful for measuring elapsed time.

Definition at line 177 of file util.cc.

Referenced by BuildStatus::BuildEdgeFinished(), BuildStatus::BuildEdgeStarted(), and main().

int MakeDir ( const string &  path)

Create a directory (mode 0777 on Unix).

Portability abstraction.

Definition at line 132 of file util.cc.

Referenced by main().

int ReadFile ( const string &  path,
string *  contents,
string *  err 
)

Read a file to a string.

Returns -errno and fills in err on error.

Definition at line 140 of file util.cc.

Referenced by main(), and Subprocess::OnPipeReady().

void SetCloseOnExec ( int  fd)

Mark a file descriptor to not be inherited on exec()s.

Definition at line 162 of file util.cc.

Referenced by BuildLog::OpenForWrite().

void Warning ( const char *  msg,
  ... 
)

Log a warning message.

Definition at line 50 of file util.cc.

Referenced by State::AddOut().