/*++ Function: RemoveDirectoryW See MSDN doc. --*/ BOOL PALAPI RemoveDirectoryW( IN LPCWSTR lpPathName) { PathCharString mb_dirPathString; int mb_size; DWORD dwLastError = 0; BOOL bRet = FALSE; size_t length; char * mb_dir = NULL; PERF_ENTRY(RemoveDirectoryW); ENTRY("RemoveDirectoryW(lpPathName=%p (%S))\n", lpPathName?lpPathName:W16_NULLSTRING, lpPathName?lpPathName:W16_NULLSTRING); if (lpPathName == NULL) { dwLastError = ERROR_PATH_NOT_FOUND; goto done; } length = (PAL_wcslen(lpPathName)+1) * 3; mb_dir = mb_dirPathString.OpenStringBuffer(length); if (NULL == mb_dir) { dwLastError = ERROR_NOT_ENOUGH_MEMORY; goto done; } mb_size = WideCharToMultiByte( CP_ACP, 0, lpPathName, -1, mb_dir, length, NULL, NULL ); if( mb_size == 0 ) { mb_dirPathString.CloseBuffer(0); ASSERT("WideCharToMultiByte failure! error is %d\n", dwLastError); dwLastError = ERROR_INTERNAL_ERROR; goto done; } mb_dirPathString.CloseBuffer(mb_size - 1); if ((bRet = RemoveDirectoryHelper (mb_dirPathString, &dwLastError))) { TRACE("Removal of directory [%s] was successful.\n", mb_dir); } done: if( dwLastError ) { SetLastError( dwLastError ); } LOGEXIT("RemoveDirectoryW returns BOOL %d\n", bRet); PERF_EXIT(RemoveDirectoryW); return bRet; }
/*++ Function: RemoveDirectoryA See MSDN doc. --*/ BOOL PALAPI RemoveDirectoryA( IN LPCSTR lpPathName) { DWORD dwLastError = 0; BOOL bRet = FALSE; PathCharString mb_dirPathString; size_t length; char * mb_dir; PERF_ENTRY(RemoveDirectoryA); ENTRY("RemoveDirectoryA(lpPathName=%p (%s))\n", lpPathName, lpPathName); if (lpPathName == NULL) { dwLastError = ERROR_PATH_NOT_FOUND; goto done; } length = strlen(lpPathName); mb_dir = mb_dirPathString.OpenStringBuffer(length); if (NULL == mb_dir) { dwLastError = ERROR_NOT_ENOUGH_MEMORY; goto done; } if (strncpy_s (mb_dir, sizeof(char) * (length+1), lpPathName, MAX_LONGPATH) != SAFECRT_SUCCESS) { mb_dirPathString.CloseBuffer(length); WARN("mb_dir is larger than MAX_LONGPATH (%d)!\n", MAX_LONGPATH); dwLastError = ERROR_FILENAME_EXCED_RANGE; goto done; } mb_dirPathString.CloseBuffer(length); bRet = RemoveDirectoryHelper (mb_dir, &dwLastError); done: if( dwLastError ) { SetLastError( dwLastError ); } LOGEXIT("RemoveDirectoryA returns BOOL %d\n", bRet); PERF_EXIT(RemoveDirectoryA); return bRet; }
/*++ Function: RemoveDirectoryA See MSDN doc. --*/ BOOL PALAPI RemoveDirectoryA( IN LPCSTR lpPathName) { DWORD dwLastError = 0; BOOL bRet = FALSE; PathCharString mb_dirPathString; PERF_ENTRY(RemoveDirectoryA); ENTRY("RemoveDirectoryA(lpPathName=%p (%s))\n", lpPathName, lpPathName); if (lpPathName == NULL) { dwLastError = ERROR_PATH_NOT_FOUND; goto done; } if (!mb_dirPathString.Set(lpPathName, strlen(lpPathName))) { WARN("Set failed !\n"); dwLastError = ERROR_NOT_ENOUGH_MEMORY; goto done; } bRet = RemoveDirectoryHelper (mb_dirPathString, &dwLastError); done: if( dwLastError ) { SetLastError( dwLastError ); } LOGEXIT("RemoveDirectoryA returns BOOL %d\n", bRet); PERF_EXIT(RemoveDirectoryA); return bRet; }