473,769 Members | 7,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1376
On Jun 28, 8:39*am, mathieu <mathieu.malate ...@gmail.comwr ote:
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
3698
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 caller by specifying a throws clause as well. is there a similar machanism in c++? i want to force a developer to write handlers for all possible exceptions a method of my class library can throw.
3
6757
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 replace the ..RC file to compile a version of my software for a different language.
12
6693
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 assert could be used to start an interactive debugger automatically. How do I realize that on a Linux machine using gcc?
2
3028
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 released, some thought must be put into how to make sure the objects will all be closed and released in the correct order, even in the result of an error. This requirement can make our code really ugly, even following the best of commonly known best...
0
1174
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 basic authentication with impersonation enable. but the french file is not loaded until an administrator access the web
0
1201
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 property Localize =true and select my language. then I have a file named form1.fr-FR.resx in my project. I use then the ressource manager class with the currentcultureinfo to set my new culture and change my different text by using teh Getstring...
5
3646
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 New System.Diagnostics.Process 'p.Start(MDEPDirStr & "macrun.exe", sPPTOut) p.Start("C:\WINDOWS\SYSTEM32\CALC.EXE") 'p.Start("C:\WINDOWS\SYSTEM32\macrun.exe", sPPTOut)
3
6894
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 VIOLATION ERROR...after that I'm getting the entry as DIA0505I Execution of a component signal handling function has begun, so my query is what does the DIA05051 actally mean.. My diag log entry is as follows:
35
3807
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 gets about 3 or so. It also gets very awkward in nested loops, where you want to check for normal loop processing in the loop condition, not errors. Yes, you could put some generic exit flag in the loop condition, but when you're simply done if...
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10216
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9997
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.