[Gpredict-svn] SF.net SVN: gpredict:[354] trunk/src
Real time satellite tracking and orbit prediction
Status: Beta
Brought to you by:
csete
|
From: <cs...@us...> - 2009-08-04 22:14:31
|
Revision: 354
http://gpredict.svn.sourceforge.net/gpredict/?rev=354&view=rev
Author: csete
Date: 2009-08-04 22:14:20 +0000 (Tue, 04 Aug 2009)
Log Message:
-----------
Changed functions to transition to new configuration files.
Modified Paths:
--------------
trunk/src/compat.c
trunk/src/compat.h
Modified: trunk/src/compat.c
===================================================================
--- trunk/src/compat.c 2009-08-04 20:32:35 UTC (rev 353)
+++ trunk/src/compat.c 2009-08-04 22:14:20 UTC (rev 354)
@@ -190,16 +190,106 @@
}
-/** \brief Get user configuration directory.
+/** \brief Get the old user configuration directory.
*
* On linux it corresponds to $HOME/.gpredict2
* The function returns a newly allocated gchar * which must be free when
* it is no longer needed.
*/
-gchar *get_conf_dir (void)
+gchar *get_old_conf_dir (void)
{
gchar *dir;
dir = g_strconcat (g_get_home_dir(), G_DIR_SEPARATOR_S, ".gpredict2", NULL);
return dir;
}
+
+
+/** \brief Get user configuration directory.
+ *
+ * Linux: $HOME/.config/Gpredict
+ * Windows: C:\Documents and Settings\username\Gpredict
+ * Mac OS X: /home/username/Library/Application Support/Gpredict
+ *
+ * The function returns a newly allocated gchar * which must be free when
+ * it is no longer needed.
+ */
+gchar *get_user_conf_dir (void)
+{
+ gchar *dir = NULL;
+
+#ifdef G_OS_UNIX
+ dir = g_strconcat (g_get_home_dir(), G_DIR_SEPARATOR_S,
+ ".config", G_DIR_SEPARATOR_S,
+ "Gpredict", NULL);
+ "icons", NULL);
+#endif
+#ifdef G_OS_WIN32
+ // FIXME: does this work?
+ dir = g_strconcat (g_get_home_dir(), G_DIR_SEPARATOR_S,
+ "Gpredict", NULL);
+#endif
+/* see gtk-osx.sourceforge.net -> Integration */
+#ifdef MAC_INTEGRATION
+ dir = g_strconcat (g_get_home_dir(), G_DIR_SEPARATOR_S,
+ "Library", G_DIR_SEPARATOR_S,
+ "Application Support", G_DIR_SEPARATOR_S,
+ "Gpredict", NULL);
+#endif
+
+ return dir;
+
+}
+
+
+/** \brief Get full path of a .sat or .cat file
+ * \param satfile The file name for the satellite
+ * \return A newly allocated gchar * that should be freed when no longer needed
+ */
+gchar *sat_file_name (const gchar *satfile)
+{
+ gchar *filename = NULL;
+ gchar *buff;
+
+ buff = get_user_conf_dir ();
+ filename = g_strconcat (buff, G_DIR_SEPARATOR_S, satdata, G_DIR_SEPARATOR_S, satfile, NULL);
+ g_free (buff);
+
+ return filename;
+
+}
+
+/** \brief Get full path of a .trsp file
+ * \param trspfile The file name for the satellite
+ * \return A newly allocated gchar * that should be freed when no longer needed
+ */
+gchar *trsp_file_name (const gchar *trspfile)
+{
+ gchar *filename = NULL;
+ gchar *buff;
+
+ buff = get_user_conf_dir ();
+ filename = g_strconcat (buff, G_DIR_SEPARATOR_S, trsp, G_DIR_SEPARATOR_S, trspfile, NULL);
+ g_free (buff);
+
+ return filename;
+
+}
+
+
+/** \brief Get full path of a .rig or .rot file
+ * \param hwfile The file name for the configuration
+ * \return A newly allocated gchar * that should be freed when no longer needed
+ */
+gchar *hw_file_name (const gchar *hwfile)
+{
+ gchar *filename = NULL;
+ gchar *buff;
+
+ buff = get_user_conf_dir ();
+ filename = g_strconcat (buff, G_DIR_SEPARATOR_S, hwconf, G_DIR_SEPARATOR_S, hwfile, NULL);
+ g_free (buff);
+
+ return filename;
+
+}
Modified: trunk/src/compat.h
===================================================================
--- trunk/src/compat.h 2009-08-04 20:32:35 UTC (rev 353)
+++ trunk/src/compat.h 2009-08-04 22:14:20 UTC (rev 354)
@@ -32,10 +32,13 @@
gchar *get_data_dir (void);
gchar *get_maps_dir (void);
gchar *get_icon_dir (void);
-gchar *get_conf_dir (void);
+gchar *get_user_conf_dir (void);
+gchar *get_old_conf_dir (void);
gchar *map_file_name (const gchar *map);
gchar *icon_file_name (const gchar *icon);
gchar *data_file_name (const gchar *data);
+gchar *sat_file_name (const gchar *satfile);
+gchar *trsp_file_name (const gchar *trspfile);
+gchar *hw_file_name (const gchar *hwfile);
-
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|