1
/*********************************************************
2
* Copyright (C) 2008 VMware, Inc. All rights reserved.
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License as published
6
* by the Free Software Foundation version 2.1 and no later version.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10
* or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
11
* License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program; if not, write to the Free Software Foundation, Inc.,
15
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17
*********************************************************/
22
* Internal, shared functions for the GTK toolbox.
27
#include <glib/gprintf.h>
28
#include <glib/gstdio.h>
33
#include "vmware/tools/utils.h"
37
*-----------------------------------------------------------------------------
39
* Toolbox_GetScriptPath --
41
* Returns the absolute path to the given script. Relative paths
42
* given as input to this function are considered to be relative
43
* to the Tools "install" path.
46
* The absolute path of the script.
51
*-----------------------------------------------------------------------------
56
Toolbox_GetScriptPath(const wchar_t *scriptUtf16) // IN
59
Toolbox_GetScriptPath(const gchar *script) // IN
67
script = g_utf16_to_utf8(scriptUtf16, -1, NULL, NULL, &err);
69
g_error("Error converting to UTF8: %s\n", err->message);
72
if (!g_path_is_absolute(script)) {
73
char *toolsPath = GuestApp_GetInstallPath();
74
ASSERT_MEM_ALLOC(toolsPath);
75
ret = g_strdup_printf("%s%c%s", toolsPath, DIRSEPC, script);
78
ret = g_strdup(script);
88
*-----------------------------------------------------------------------------
90
* Toolbox_LoadToolsConf --
92
* Load the Tools configuration file from the default location.
94
* XXX: This function is temporary until the GTK toolbox is refactored
95
* to be able to use vmtoolslib.
98
* The config object. If loading the data fails, returns an empty conf object.
103
*-----------------------------------------------------------------------------
107
Toolbox_LoadToolsConf(void)
109
GKeyFile *config = NULL;
111
VMTools_LoadConfig(NULL,
112
G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS,
116
if (config == NULL) {
117
Debug("Unable to load config file.\n");
118
config = g_key_file_new();
126
*-----------------------------------------------------------------------------
128
* Toolbox_SaveToolsConf --
130
* Saves the given config data to the default tools config file location.
132
* XXX: This function is temporary until the GTK toolbox is refactored
133
* to be able to use vmtoolslib.
136
* Whether saving was successful.
141
*-----------------------------------------------------------------------------
145
Toolbox_SaveToolsConf(GKeyFile *config) // IN
147
gboolean ret = FALSE;
150
ret = VMTools_WriteConfig(NULL, config, &err);
153
Warning("Error saving conf data: %s\n", err->message);