Doxygen
portable.cpp 文件参考
#include "portable.h"
#include "qcstring.h"
#include <stdlib.h>
#include <stdio.h>
#include <chrono>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
#include <assert.h>
#include <ctype.h>
#include <map>
#include <string>
#include "fileinfo.h"
#include "util.h"
#include "dir.h"
#include "debug.h"
+ portable.cpp 的引用(Include)关系图:

浏览源代码.

函数

void loadEnvironment ()
 
static bool ExistsOnPath (const QCString &fileName)
 
static const char * portable_memmem (const char *haystack, size_t haystack_len, const char *needle, size_t needle_len)
 

变量

char ** environ
 
static bool environmentLoaded = false
 
static std::map< std::string, std::string > proc_env = std::map<std::string,std::string>()
 
static double g_sysElapsedTime
 
static std::chrono::steady_clock::time_point g_startTime
 

函数说明

◆ ExistsOnPath()

static bool ExistsOnPath ( const QCString fileName)
static

在文件 portable.cpp365 行定义.

366 {
367  FileInfo fi1(fileName.str());
368  if (fi1.exists()) return true;
369 
370  QCString paths = Portable::getenv("PATH");
371  char listSep = Portable::pathListSeparator()[0];
372  char pathSep = Portable::pathSeparator()[0];
373  int strt = 0;
374  int idx;
375  while ((idx = paths.find(listSep,strt)) != -1)
376  {
377  QCString locFile(paths.mid(strt,idx-strt));
378  locFile += pathSep;
379  locFile += fileName;
380  FileInfo fi(locFile.str());
381  if (fi.exists()) return true;
382  strt = idx + 1;
383  }
384  // to be sure the last path component is checked as well
385  QCString locFile(paths.mid(strt));
386  if (!locFile.isEmpty())
387  {
388  locFile += pathSep;
389  locFile += fileName;
390  FileInfo fi(locFile.str());
391  if (fi.exists()) return true;
392  }
393  return false;
394 }

引用了 FileInfo::exists(), QCString::find(), Portable::getenv(), QCString::isEmpty(), QCString::mid(), Portable::pathListSeparator(), Portable::pathSeparator() , 以及 QCString::str().

被这些函数引用 Portable::checkForExecutable() , 以及 Portable::ghostScriptCommand().

◆ loadEnvironment()

void loadEnvironment ( )

在文件 portable.cpp219 行定义.

220 {
221  if(environ != NULL)
222  {
223  unsigned int i = 0;
224  char* current = environ[i];
225 
226  while(current != NULL) // parse all strings contained by environ til the last element (NULL)
227  {
228  std::string env_var(current); // load current environment variable string
229  size_t pos = env_var.find("=");
230  if(pos != std::string::npos) // only parse the variable, if it is a valid environment variable...
231  { // ...which has to contain an equal sign as delimiter by definition
232  std::string name = env_var.substr(0,pos); // the string til the equal sign contains the name
233  std::string value = env_var.substr(pos + 1); // the string from the equal sign contains the value
234 
235  proc_env[name] = value; // save the value by the name as its key in the classes map
236  }
237  i++;
238  current = environ[i];
239  }
240  }
241 
242  environmentLoaded = true;
243 }

引用了 environ, environmentLoaded , 以及 proc_env.

被这些函数引用 Portable::getenv() , 以及 Portable::setenv().

◆ portable_memmem()

static const char* portable_memmem ( const char *  haystack,
size_t  haystack_len,
const char *  needle,
size_t  needle_len 
)
static

在文件 portable.cpp553 行定义.

555 {
556  const char *const last_possible = haystack + haystack_len - needle_len;
557 
558  if (needle_len == 0)
559  // The first occurrence of the empty string should to occur at the beginning of the string.
560  {
561  return haystack;
562  }
563 
564  // Sanity check
565  if (haystack_len < needle_len)
566  {
567  return 0;
568  }
569 
570  for (const char *begin = haystack; begin <= last_possible; ++begin)
571  {
572  if (begin[0] == needle[0] && !memcmp(&begin[1], needle + 1, needle_len - 1))
573  {
574  return begin;
575  }
576  }
577 
578  return 0;
579 }

引用了 begin().

被这些函数引用 Portable::strnstr().

变量说明

◆ environ

char** environ

被这些函数引用 loadEnvironment() , 以及 Portable::system().

◆ environmentLoaded

bool environmentLoaded = false
static

在文件 portable.cpp34 行定义.

被这些函数引用 Portable::getenv(), loadEnvironment() , 以及 Portable::setenv().

◆ g_startTime

std::chrono::steady_clock::time_point g_startTime
static

在文件 portable.cpp39 行定义.

被这些函数引用 Portable::sysTimerStart() , 以及 Portable::sysTimerStop().

◆ g_sysElapsedTime

double g_sysElapsedTime
static

在文件 portable.cpp38 行定义.

被这些函数引用 Portable::getSysElapsedTime() , 以及 Portable::sysTimerStop().

◆ proc_env

std::map<std::string,std::string> proc_env = std::map<std::string,std::string>()
static

在文件 portable.cpp35 行定义.

被这些函数引用 Portable::getenv(), loadEnvironment(), Portable::setenv() , 以及 Portable::unsetenv().

Portable::pathSeparator
QCString pathSeparator()
Definition: portable.cpp:347
environmentLoaded
static bool environmentLoaded
Definition: portable.cpp:34
QCString::str
std::string str() const
Definition: qcstring.h:442
QCString::find
int find(char c, int index=0, bool cs=TRUE) const
Definition: qcstring.cpp:38
begin
DirIterator begin(DirIterator it) noexcept
Definition: dir.cpp:123
Portable::getenv
QCString getenv(const QCString &variable)
Definition: portable.cpp:279
Portable::pathListSeparator
QCString pathListSeparator()
Definition: portable.cpp:356
QCString::mid
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition: qcstring.h:224
proc_env
static std::map< std::string, std::string > proc_env
Definition: portable.cpp:35
FileInfo
Minimal replacement for QFileInfo.
Definition: fileinfo.h:22
environ
char ** environ
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108