473,386 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Handling external ressource (aka How can I find a process' executablefile)

Hi,

This is slightly off-topic (not purely C++). But I was wondering how
do people handle ressources (input file) in their C++ applications in
a cross platform way ?
I tought first of using relative path from the current running
executable, but I could not find a portable way of doing other than
getcwd/_getcwd + argv[0] which may or may not always work.

My current implementation is to produce a C++ file that gets
compiled during the build:

http://gdcm.svn.sourceforge.net/view...xx?view=markup

Thanks for suggestions !
-Mathieu
Jun 28 '08 #1
1 1361
On Jun 28, 8:39*am, mathieu <mathieu.malate...@gmail.comwrote:
Hi,

* This is slightly off-topic (not purely C++). But I was wondering how
do people handle ressources (input file) in their C++ applications in
a cross platform way ?
* I tought first of using relative path from the current running
executable, but I could not find a portable way of doing other than
getcwd/_getcwd + argv[0] which may or may not always work.

* My current implementation is to produce a C++ file that gets
compiled during the build:

http://gdcm.svn.sourceforge.net/view...e/DataDictiona...

Thanks for suggestions !
-Mathieu
In the systems I've done, code in core libraries use fully qualified
path names and it's the job of the application to supply those names
to the libraries.

For apps, you can easily use environment variables which specify the
full path name or the path excluding the filename. If I'm not
mistaken
getenv is part of the C library which makes it cross platform.

But I found that sprinkling getenv calls around code can lead to a
maintenance headaches so what I did was put everything in a config
file
and have the app take the config file name as it's only command line
arg.

The config file is just name/value pairs and can be any format you
like. But the key point is that I allow values inside the config
file to be specified using environment variables. Inside my cofig
file processing I expand the environment variables myself.

This approach has the benefit of environment variables but has
everything
centralized in one place - the config file.

HTH
Jun 28 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Ritz, Bruno | last post by:
hi in java i found that when a method has a throws clause in the definition, callers must either handle the exceptions thrown by the method they are calling or "forward" the exception to the...
3
by: Rolf Hemmerling | last post by:
Hello ! Beginner's question: Howto access .RC/.RES Ressource files with portable C++ code ( BCC,MSVC,GNU-C++, OpenWatcom) ? I just wanna access "local language strings", so that I may...
12
by: Christian Christmann | last post by:
Hi, assert and error handling can be used for similar purposes. When should one use assert instead of try/catch and in which cases the error handling is preferable? I've read somewhere that...
2
by: Steve Jorgensen | last post by:
When writing VB or VBA code that works with databases or other external libraries that cannot be trusted to automatically do the right thing when references to their objects are arbitrarily...
0
by: Jéjé | last post by:
Hi, I have a web site in ASP.NET which use a compiled ressource file for the french version. (dlls of web controls) My DLLs are in the GAC. My website use the NT authentication and/or the...
0
by: calderara serge | last post by:
Dear all, I have an application which is plan to be language dependant. I have make some testing by using ressource files which have been automatically added to my form by setting the form...
5
by: snicks | last post by:
I'm trying to exec a program external to my ASP.NET app using the following code. The external app is a VB.NET application. Dim sPPTOut As String sPPTOut = MDEPDirStr + sID + ".ppt" Dim p As...
3
by: vijay.db | last post by:
Hi Group, Running DB2 V8.2 Fxpack 9 in AIX 5.2, I get the following error frequently and my instance is stopped...collected some info like: the signal received is 11 which is SEGMENTATION...
35
by: jeffc226 | last post by:
I'm interested in an idiom for handling errors in functions without using traditional nested ifs, because I think that can be very awkward and difficult to maintain, when the number of error checks...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.