Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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: 698
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: Fri May 10 08:12:11 CEST 2024

Total time taken to generate the page: 0.02968 seconds