获取当前绝对路径

std::string getCurModuleDir()

{

  enum {BUF_LEN =1024};

  char pcDirection[BUF_LEN];

  memset(pcDirection,0,sizeof(pcDirection));

#if defined(WIN32)

  GetModuleFileNameA(NULL,pcDirection,BUF_LEN);

#else

  readlink("/proc/self/exe",pcDirection,BUF_LEN);

#endif

  for(int i=(int)strlen(pcDirection);i>=0;i--)

{

#if defined(WIN32)

  if(pcDirection[i]=='\\')

#else

  if(pcDirection[i]=='/')

#endif

{

  pcDirection[i+1] ='\0';

}

return pcDirection;

}

 

上一篇:解决渲染进程里无法使用node模块`Uncaught ReferenceError: require is not defined`


下一篇:js函数明明已经定义,却显示xxx()is not defined的解决办法