LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-14-2004, 12:25 PM   #1
Zotty
LQ Newbie
 
Registered: Sep 2004
Location: Netherlands
Distribution: Debian testing
Posts: 25

Rep: Reputation: 15
Configurationfile naming and placement


I'm working on a program which uses a configuration file (in XML) to store it's settings. As I'm new to programming under Linux I was wondering what would be the best place to store it and what would be a good naming scheme. It should be distribution independant.

Also if for example the file is stored in a user's home directory, how do I check where it is located in C++? Or is it common to place it in the same directory as the program itself?
 
Old 09-14-2004, 01:55 PM   #2
Proud
Senior Member
 
Registered: Dec 2002
Location: England
Distribution: Used to use Mandrake/Mandriva
Posts: 2,794

Rep: Reputation: 116Reputation: 116
Just store it in ~/.appname and then use an error catching bit of code to check a file's there and try to read it. If no-go, tell the user the config is missing, and maybe assume defaults or end.
 
Old 09-14-2004, 05:07 PM   #3
Zotty
LQ Newbie
 
Registered: Sep 2004
Location: Netherlands
Distribution: Debian testing
Posts: 25

Original Poster
Rep: Reputation: 15
Oh yeah, that's right! Didn't thought of that ~ character yet... so silly, still got to get those things in my mind

Thank you! That answered my question.
 
Old 09-14-2004, 05:39 PM   #4
Proud
Senior Member
 
Registered: Dec 2002
Location: England
Distribution: Used to use Mandrake/Mandriva
Posts: 2,794

Rep: Reputation: 116Reputation: 116
I think ~ always translates to the home directory set in /etc/passwd but you'd best check. Try the code of some other GPL apps.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mail server the naming naming convention problem kashan Linux - Newbie 0 07-16-2004 02:08 PM
Directory placement JROCK1980 Slackware 1 11-11-2003 11:09 PM
Windows Placement enlight1 Linux - Newbie 4 06-18-2003 12:26 AM
Window Placement enlight1 Linux - Distributions 1 06-17-2003 05:46 PM
window placement JunLitsu Linux - Software 0 04-24-2003 12:47 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration