Stellarium 0.12.3
1 /*
2  * Stellarium
3  * Copyright (C) 2009 Matthew Gates
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19 *</tt>: landscape textures and data files</li>
68 </ul>
70 </li>
71 </ul>
73 If a file exists in the <em>User Data Directory</em>, it will be used in preference to a file with the same name existing in the <em>Installation Data Directory</em>. This allows users to customise data files, textures and so on without modifying the originally installed files.
75 There are several reasons for doing this:
76 <ul>
77  <li>On machines which multiple user accounts, the <em>Installation Data Directory</em> will likely not be writable by all users. Without allowing the <em>User Data Directory</em> files to over-ride <em>Installation Data Directory</em> files such users could not customise the program without doing an entirely separate installation.</li>
78  <li>On multi-user systems, different users can customise Stellarium without affecting other users of the program.</li>
79  <li>Users who modify files in the <em>Installation Data Directory</em> will likely have their work deleted or overwritten when they upgrade Stellarium. By keeping user-customised files separate from the installation, the upgrade procedure is easier to manage, and users have better security for their work.</li>
80  <li>Users who mess up a customisation attempt need only remove the <em>User Data Directory</em> copy of a file to return to the original (working) copy.</li>
81 </ul>
83 @section findingFile Finding files with the StelFileMgr class
85 Whenever a file is needed in Stellarium, it should be located using the StelFileMgr class. This class will find the file in the first location in the search path. An instance of this class is maintained by the StelApp singleton. StelFileMgr::findFile() will throw exceptions when a problem is encountered, so it is important to always use <tt>try ... catch ...</tt> exception handling when using it.
87 For example. You are writing a class called Comet, and wish to search for a data file called <tt>comets.dat</tt> located in the <tt>data</tt> directory, you would go about it like this:
89 @code
90 QString path;
91 try
92 {
93  path = StelApp::getInstance().getFileMgr().findFile("data/comets.dat");
94 }
95 catch(std::runtime_error& e)
96 {
97  qWarning() << "Could not locate file: data/comets.dat : " << e.what();
98 }
99 ...
100 @endcode
102 As you can see, the file is specified only by the partial path. This partial path is appended first to the <em>User Data Directory</em>. If, and only if the file is not found there, it is searched for in the <em>Installation Data Directory</em>. Thus if the user has a customised copy at: <tt>\<User Data Directory>/data/comets.dat</tt> it will be used, else the version in the <em>Installation Data Directory</em> will be used.
104 @section exampleStarCatalogTool Example: Star Catalogue Download Tool
105 Stellarium ships with the first four star catalogue files of nine files. The implementation of a catalogue downloading tool helps ease the task for users wanting the extra catalogues by automating the download and installation procedure.
107 The files which come with Stellarium are found by the partial paths:
108 @verbatim
109 stars/default/
110 stars/default/
111 stars/default/
112 stars/default/
113 @endverbatim
115 Naturally, these files are to be located in the <em>Installation Data Directory</em> (because they ship with the installer).
117 The catalogue downloader tool runs within Stellarium. When it downloads extra star catalogue files, it should place them in the <em>User Data Directory</em>. After downloading all the catalogues, the paths to the various files should look like this:
119 @verbatim
120 <Installation Data Directory>/stars/default/
121 <Installation Data Directory>/stars/default/
122 <Installation Data Directory>/stars/default/
123 <Installation Data Directory>/stars/default/
124 <User Data Directory>/stars/default/
125 <User Data Directory>/stars/default/
126 <User Data Directory>/stars/default/
127 <User Data Directory>/stars/default/
128 <User Data Directory>/stars/default/
129 @endverbatim
131 It might be that someone makes a customised installer of Stellarium which includes all the star catalogues with the main installation - perhaps on a special edition DVD. In this case, all the files would be in the <em> \<Installation Data Directory>/stars/default</em> directory. The downloader tool should be able to cope with this, not re-downloading files into the <em>User Data Directory</em> which already reside in the <em>Installation Data Directory</em>.
133 */