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: 702
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: Sat Aug 16 03:19:50 CEST 2025

Total time taken to generate the page: 0.06768 seconds