On 12/18/19 12:53 PM, Fabiano FidĂȘncio wrote:
Let's just use the plain g_get_home_dir(), from GLib, instead of
maintaining a code adapted from the GLib's one.
Signed-off-by: Fabiano FidĂȘncio <fidencio(a)redhat.com>
---
src/util/virutil.c | 92 +---------------------------------------------
1 file changed, 1 insertion(+), 91 deletions(-)
diff --git a/src/util/virutil.c b/src/util/virutil.c
index a28feb3daa..4075047cf9 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -1070,100 +1070,10 @@ virDoesGroupExist(const char *name G_GNUC_UNUSED)
}
# ifdef WIN32
-/* These methods are adapted from GLib2 under terms of LGPLv2+ */
-static int
-virGetWin32SpecialFolder(int csidl, char **path)
-{
- char buf[MAX_PATH+1];
- LPITEMIDLIST pidl = NULL;
- int ret = 0;
-
- *path = NULL;
-
- if (SHGetSpecialFolderLocation(NULL, csidl, &pidl) == S_OK) {
- if (SHGetPathFromIDList(pidl, buf))
- *path = g_strdup(buf);
- CoTaskMemFree(pidl);
- }
- return ret;
-}
-
-static int
-virGetWin32DirectoryRoot(char **path)
-{
- char windowsdir[MAX_PATH];
-
- *path = NULL;
-
- if (GetWindowsDirectory(windowsdir, G_N_ELEMENTS(windowsdir))) {
- const char *tmp;
- /* Usually X:\Windows, but in terminal server environments
- * might be an UNC path, AFAIK.
- */
- tmp = virFileSkipRoot(windowsdir);
- if (VIR_FILE_IS_DIR_SEPARATOR(tmp[-1]) &&
- tmp[-2] != ':')
- tmp--;
-
- windowsdir[tmp - windowsdir] = '\0';
- } else {
- strcpy(windowsdir, "C:\\");
- }
-
- *path = g_strdup(windowsdir);
- return 0;
-}
-
-
-
char *
virGetUserDirectoryByUID(uid_t uid G_GNUC_UNUSED)
{
- /* Since Windows lacks setuid binaries, and since we already fake
- * geteuid(), we can safely assume that this is only called when
- * querying about the current user */
Keep this comment, it explains why this function does not abide the
passed in uid argument. With that:
Reviewed-by: Cole Robinson <crobinso(a)redhat.com>
After this, virFileSkipRoot and virFileIsAbsPath are no longer used, and
after that I think VIR_FILE_IS_DIR_SEPARATOR, maybe check for others.
Should be a follow up patch though
- Cole