LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 02-09-2007, 09:27 AM   #1
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Blog Entries: 1

Rep: Reputation: 90
Question equivalent of /etc/projectname/ in windows


I'm creating a C++ project (based on Qt) and I'm about to read the configuration file of the project.

In *nix, the route would be something like /etc/projectname/projectname.rc or something like that... however, in Windows it could be "C:\Program Files\projectname\" or "C:\Archivos de programa\projectname\" (and others depending on the language) or the place where the user decided to place the file. Is there a way that this default location (program files, archivos de programa, etc, not considering user defined locations) can be gotten so I can make up the default route?
 
Old 02-09-2007, 10:01 AM   #2
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Typically, in a recent Windows system, the basic information would be in the registry. That information would include the location of the application and of it's "configuration file." Again, typically, configuration files are avoided in Windows, and the application preferences stored in the registry.

Older Windows systems used "<app_name>.ini" files stored in C:\Windows\, although, IIRC, XP uses %system_root%\%system_home\" and you could, in principle, store you configuration information there. If the information is user specific, and you anticipate multiple users, something like C:\Windows\<app_name)_<user_name>.ini might also work.

Note, please, that this is a Linux questions forum, and -- again, typically -- you will receive flack from some people offended by Windows questions.
 
Old 02-09-2007, 10:13 AM   #3
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
Three things:

I definitely don't want to go the windows registry route. So I'll probably stick with the ini files in c:\windows\blah blah

Second... I wanted to make sure I hadn't misread... and I didn't. Right on top of the Programming forum, I read: "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." So I guess Windows related questions are OK... aren't they? ;-) Anyway... I promise not to ask a lot about windows... The fact that I hate it is the most compelling reason not to bother myself thinking a lot about it. :-)

And third: I'm actually programming on linux.... but the system is intended to be working on linux/windows or wherever Qt is supported. I have a number of
Code:
#ifdef linux 

#endif 
#ifdef WIN32 
#endif
spread in the project.
 
Old 02-09-2007, 10:23 AM   #4
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
QT has a class that will handle that all for you... QSettings
 
Old 02-10-2007, 12:20 PM   #5
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
In my commercial app, I stay away from the registry to the extent that is humanly possible (I do have to write a couple of things to it in order for it to work properly with windows).

I have created an etc subdirectory under my program's main install directory and this is where I place all configuration files. Aside from the fact that this keeps me away from that gawdawful registry, it will prove very helpful for my next version, which will be multi-platform (including Linux).
 
Old 02-10-2007, 12:46 PM   #6
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
After a little research into windows' environment variables, I found this:

ProgramFiles: It keeps the default location of programs to be installed. In english: C:\Program Files, in spanish: C:\Archivos de Programa\, etc etc

USERPROFILE: It's like GNU/linux's (*nix???) HOME environment variable.

Hope it's helpful to anyone.
 
Old 02-10-2007, 02:57 PM   #7
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
You can, I believe, use the symbolic name "%ProgramFilesDir%" in place of the C:\... name, which is usually more portable and not language specific. (That's from a "google," not actual usage by me.)
 
  


Reply



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
What equivalent of MSDN (in MS Windows ) is in Linux Igor007 Programming 9 05-15-2009 09:35 AM
Start equivalent of windows in linux MRMadhav General 8 06-08-2006 02:05 PM
Windows equivalent distro redfedora88 Linux - Distributions 24 03-26-2006 03:27 PM
Equivalent to windows Charmap? robertmarkbram Linux - General 2 12-02-2003 06:39 PM
?Iptables equivalent in windows pudhiyavan Linux - Security 1 11-06-2003 10:54 PM

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

All times are GMT -5. The time now is 06:14 PM.

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