diff options
author | Evan Martin <martine@danga.com> | 2012-09-13 22:33:40 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2012-09-13 22:33:40 (GMT) |
commit | 7096bf1507f98be981aa14ffd9ed5a4a8b1c1494 (patch) | |
tree | 10f75334ddb1dc86c2cc85db0cab93ca672d39de /src/util.h | |
parent | 50af448b293b411bde5232931525574aba3bb451 (diff) | |
parent | 06fa62352d1e9868409b299ffc8abc8f4cd9a39d (diff) | |
download | Ninja-1.0.0.zip Ninja-1.0.0.tar.gz Ninja-1.0.0.tar.bz2 |
version 1.0.0v1.0.0
Diffstat (limited to 'src/util.h')
-rw-r--r-- | src/util.h | 28 |
1 files changed, 14 insertions, 14 deletions
@@ -14,7 +14,6 @@ #ifndef NINJA_UTIL_H_ #define NINJA_UTIL_H_ -#pragma once #ifdef _WIN32 #include "win32port.h" @@ -26,8 +25,6 @@ #include <vector> using namespace std; -#define NINJA_UNUSED_ARG(arg_name) (void)arg_name; - /// Log a fatal message and exit. void Fatal(const char* msg, ...); @@ -40,24 +37,16 @@ void Error(const char* msg, ...); /// Canonicalize a path like "foo/../bar.h" into just "bar.h". bool CanonicalizePath(string* path, string* err); -bool CanonicalizePath(char* path, int* len, string* err); - -/// Create a directory (mode 0777 on Unix). -/// Portability abstraction. -int MakeDir(const string& path); +bool CanonicalizePath(char* path, size_t* len, string* err); -/// Read a file to a string. +/// Read a file to a string (in text mode: with CRLF conversion +/// on Windows). /// Returns -errno and fills in \a err on error. int ReadFile(const string& path, string* contents, string* err); /// Mark a file descriptor to not be inherited on exec()s. void SetCloseOnExec(int fd); -/// Get the current time as relative to some epoch. -/// Epoch varies between platforms; only useful for measuring elapsed -/// time. -int64_t GetTimeMillis(); - /// Given a misspelled string and a list of correct spellings, returns /// the closest match or NULL if there is no close enough match. const char* SpellcheckStringV(const string& text, const vector<const char*>& words); @@ -68,10 +57,18 @@ const char* SpellcheckString(const string& text, ...); /// Removes all Ansi escape codes (http://www.termsys.demon.co.uk/vtansi.htm). string StripAnsiEscapeCodes(const string& in); +/// @return the number of processors on the machine. Useful for an initial +/// guess for how many jobs to run in parallel. @return 0 on error. +int GetProcessorCount(); + /// @return the load average of the machine. A negative value is returned /// on error. double GetLoadAverage(); +/// Elide the given string @a str with '...' in the middle if the length +/// exceeds @a width. +string ElideMiddle(const string& str, size_t width); + #ifdef _MSC_VER #define snprintf _snprintf #define fileno _fileno @@ -83,6 +80,9 @@ double GetLoadAverage(); #ifdef _WIN32 /// Convert the value returned by GetLastError() into a string. string GetLastErrorString(); + +/// Calls Fatal() with a function name and GetLastErrorString. +void Win32Fatal(const char* function); #endif #endif // NINJA_UTIL_H_ |