#include <infolines.h>
Inheritance diagram for ExecLocation:
Public Member Functions | |
ExecLocation () | |
virtual | operator const char * () const |
Protected Attributes | |
char * | _infoLine |
|
Definition at line 373 of file platfDepend.cxx. References InfoLine::_infoLine.
00374 { 00375 char buf[1000]=""; 00376 #ifdef linux 00377 readlink("/proc/self/exe", buf, 1000); 00378 int pos=strlen(buf)-1; 00379 for (;pos>=0;pos--) 00380 { 00381 if (buf[pos]=='/') 00382 { 00383 buf[pos]='\0'; 00384 break; 00385 } 00386 } 00387 #endif 00388 00389 #if defined(sun) || defined(__SUNPRO_CC) 00390 pid_t pid=getpid(); 00391 char tempfname[100]=""; 00392 sprintf(tempfname,"/tmp/atempf%d",static_cast<int>(pid)); 00393 sprintf(buf,"/usr/proc/bin/ptree %d | tail -4 > %s", 00394 static_cast<int>(pid),tempfname); 00395 system(buf); 00396 { ifstream ifs(tempfname); ifs >> buf; ifs >> buf;} 00397 unlink(tempfname); 00398 if (buf[0]!='/') 00399 { 00400 if (strrchr(buf,'/')==NULL) 00401 { getcwd(buf,1000); _infoLine=strdup(buf); return; } 00402 else 00403 { 00404 char buf1[500]="",buf2[1000]=""; 00405 getcwd(buf1,500); 00406 strncpy(buf2,buf,500); 00407 sprintf(buf,"%s/%s",buf1,buf2); 00408 } 00409 } 00410 char *lastDelim=strrchr(buf,'/'); 00411 if (lastDelim==NULL) sprintf(buf,"Cannot find"); 00412 else *lastDelim='\0'; 00413 #elif defined(_MSC_VER) 00414 ::GetModuleFileName(NULL,buf,995); 00415 char drv[_MAX_DRIVE],dir[_MAX_DIR],fname[_MAX_FNAME],ext[_MAX_EXT]; 00416 _splitpath(buf,drv,dir,fname,ext); 00417 _makepath(buf,drv,dir,"",""); 00418 int len=strlen(buf); 00419 if (buf[len-1]=='\\') buf[len-1]='\0'; 00420 #endif 00421 00422 _infoLine=strdup(buf); 00423 } |
|
Definition at line 79 of file infolines.h. References InfoLine::_infoLine.
00079 { return _infoLine; } |
|
Definition at line 75 of file infolines.h. Referenced by CmdLine::CmdLine(), ExecLocation(), InfoLine::InfoLine(), InfoLine::operator const char *(), Platform::Platform(), TimeStamp::TimeStamp(), User::User(), UserHomeDir::UserHomeDir(), and InfoLine::~InfoLine(). |