U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » U++ Core » GetExeFilePath() in Linux
GetExeFilePath() in Linux [message #6334] Tue, 07 November 2006 00:47 Go to previous message
zsolt is currently offline  zsolt
Messages: 704
Registered: December 2005
Location: Budapest, Hungary
Contributor
I have implemented GetExeFilePath(). It is a little bit tricky, I dont know if it is able to work in BSD systems, but OK for Linux. It is based on the proc filesystem, as there is no standard posix function to this problem (AFAIK).
String GetExeFilePath()
{
	char h[_MAX_PATH + 1];
	String link;
	link << "/proc/" << getpid() << "/exe";
	int ret = readlink(link, h, _MAX_PATH);
	if(ret == -1 || ret > _MAX_PATH)
		return "";
	h[ret] = 0;
	return FromSystemCharset(h);
}

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Double formatting bug?
Next Topic: How to catch keyboard input?
Goto Forum:
  


Current Time: Wed Jul 15 13:06:58 GMT+2 2026

Total time taken to generate the page: 0.00721 seconds