From: Oliver Kurth Date: Fri, 2 Nov 2018 22:28:21 +0000 (-0700) Subject: Backout the previous changes to DnD temp file clean up.. X-Git-Tag: stable-11.0.0~337 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=512afce3d5f147fad4bc3fec57e93a862033ffdf;p=thirdparty%2Fopen-vm-tools.git Backout the previous changes to DnD temp file clean up.. --- diff --git a/open-vm-tools/services/plugins/dndcp/dnd/dnd.h b/open-vm-tools/services/plugins/dndcp/dnd/dnd.h index 4b8d4856e..90f108c6b 100644 --- a/open-vm-tools/services/plugins/dndcp/dnd/dnd.h +++ b/open-vm-tools/services/plugins/dndcp/dnd/dnd.h @@ -273,9 +273,7 @@ Bool DnD_UriIsNonFileSchemes(char const *uri); */ const char *DnD_GetFileRoot(void); char *DnD_CreateStagingDirectory(void); -char *DnD_AppendPrefixToStagingDir(const char *oldName, const char *newName); Bool DnD_DeleteStagingFiles(const char *stagingDir, Bool onReboot); -Bool DnD_RemoveTempDirs(const char *dndTempDir, const char *prefix); int DnD_LegacyConvertToCPName(const char *nameIn, size_t bufOutSize, char *bufOut); diff --git a/open-vm-tools/services/plugins/dndcp/dnd/dndCommon.c b/open-vm-tools/services/plugins/dndcp/dnd/dndCommon.c index d9d9d22fb..973d29519 100644 --- a/open-vm-tools/services/plugins/dndcp/dnd/dndCommon.c +++ b/open-vm-tools/services/plugins/dndcp/dnd/dndCommon.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2005-2018 VMware, Inc. All rights reserved. + * Copyright (C) 2005-2017 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -164,44 +164,6 @@ exit: #endif // ifndef DND_IS_XDG -/* - *----------------------------------------------------------------------------- - * - * DnD_AppendPrefixToStagingDir -- - * - * Append prefix to a DnD staging directory - * - * Results: - * Return new DnD staging directory for success, NULL otherwise. - * - * Side effects: - * Caller must free the retrun string with free - * - *----------------------------------------------------------------------------- - */ -char * -DnD_AppendPrefixToStagingDir(const char *stagingDir, // IN: - const char *prefix) // IN: -{ - const char *dndRoot = NULL; - char *newDir = NULL; - - dndRoot = DnD_GetFileRoot(); - if (Unicode_Find(stagingDir, dndRoot) == UNICODE_INDEX_NOT_FOUND) { - // incorrect staging directory - Log("%s: Not find root = %s\n", __FUNCTION__, dndRoot); - return NULL; - } - - newDir = Unicode_Insert(stagingDir, Unicode_LengthInCodePoints(dndRoot), prefix); - if (0 != File_Rename(stagingDir, newDir)) { - free(newDir); - newDir = NULL; - } - return newDir; -} - - /* *----------------------------------------------------------------------------- * @@ -251,8 +213,6 @@ DnD_DeleteStagingFiles(const char *stagingDir, // IN: if (numFiles == -1) { return FALSE; - } else if (numFiles == 0) { - return TRUE; } /* delete everything in the directory */ @@ -277,71 +237,8 @@ DnD_DeleteStagingFiles(const char *stagingDir, // IN: } free(base); - Util_FreeStringList(fileList, numFiles); - } - - return ret; -} - - -/* - *----------------------------------------------------------------------------- - * - * DnD_RemoveTempDirs -- - * - * Remove all directories with the specific prefix in the staging directory. - * - * Results: - * TRUE if the specific directories were deleted. FALSE if there was an error. - * - * Side effects: - * None - * - *----------------------------------------------------------------------------- - */ - -Bool -DnD_RemoveTempDirs(const char *dndTempDir, // IN: - const char *prefix) // IN: -{ - Bool ret = TRUE; - int i = 0; - int numFiles = 0; - char *base = NULL; - char **fileList = NULL; - - ASSERT(dndTempDir); - - if (!File_Exists(dndTempDir)) { - /* The dndTempDir doesn't exist. */ - return TRUE; - } - - if (!File_IsDirectory(dndTempDir)) { - return FALSE; } - /* get list of files in current directory */ - numFiles = File_ListDirectory(dndTempDir, &fileList); - if (numFiles == -1) { - return FALSE; - } else if (numFiles == 0) { - return TRUE; - } - - base = Unicode_Append(dndTempDir, DIRSEPS); - for (i = 0; i < numFiles; i++) { - char *curPath = Unicode_Append(base, fileList[i]); - if (File_IsDirectory(curPath) && - (UNICODE_INDEX_NOT_FOUND != Unicode_Find(curPath, prefix))) { - if (!File_DeleteDirectoryTree(curPath)) { - ret = FALSE; - } - } - free(curPath); - } - free(base); - Util_FreeStringList(fileList, numFiles); return ret; }