aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform
diff options
context:
space:
mode:
authormonster <monster@ydb.tech>2022-07-07 14:41:37 +0300
committermonster <monster@ydb.tech>2022-07-07 14:41:37 +0300
commit06e5c21a835c0e923506c4ff27929f34e00761c2 (patch)
tree75efcbc6854ef9bd476eb8bf00cc5c900da436a2 /contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform
parent03f024c4412e3aa613bb543cf1660176320ba8f4 (diff)
downloadydb-06e5c21a835c0e923506c4ff27929f34e00761c2.tar.gz
fix ya.make
Diffstat (limited to 'contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform')
-rw-r--r--contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform/windows/Environment.cpp37
-rw-r--r--contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform/windows/FileSystem.cpp336
-rw-r--r--contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform/windows/OSVersionInfo.cpp138
-rw-r--r--contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform/windows/Security.cpp21
-rw-r--r--contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform/windows/Time.cpp31
5 files changed, 0 insertions, 563 deletions
diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform/windows/Environment.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform/windows/Environment.cpp
deleted file mode 100644
index d8b5403123..0000000000
--- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform/windows/Environment.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
- * SPDX-License-Identifier: Apache-2.0.
- */
-
-#include <aws/core/platform/Environment.h>
-
-#include <stdio.h>
-#include <utility>
-
-namespace Aws
-{
-namespace Environment
-{
-
-/*
-using std::getenv generates a warning on windows so we use _dupenv_s instead. The character array returned by this function is our responsibility to clean up, so rather than returning raw strings
-that would need to be manually freed in all the client functions, just copy it into a Aws::String instead, freeing it here.
-*/
-Aws::String GetEnv(const char *variableName)
-{
- char* variableValue = nullptr;
- std::size_t valueSize = 0;
- auto queryResult = _dupenv_s(&variableValue, &valueSize, variableName);
-
- Aws::String result;
- if(queryResult == 0 && variableValue != nullptr && valueSize > 0)
- {
- result.assign(variableValue, valueSize - 1); // don't copy the c-string terminator byte
- free(variableValue);
- }
-
- return result;
-}
-
-} // namespace Environment
-} // namespace Aws
diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform/windows/FileSystem.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform/windows/FileSystem.cpp
deleted file mode 100644
index 2ea82de6f8..0000000000
--- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform/windows/FileSystem.cpp
+++ /dev/null
@@ -1,336 +0,0 @@
-/**
- * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
- * SPDX-License-Identifier: Apache-2.0.
- */
-#include <aws/core/platform/FileSystem.h>
-
-#include <aws/core/platform/Environment.h>
-#include <aws/core/utils/logging/LogMacros.h>
-#include <aws/core/utils/StringUtils.h>
-#include <cassert>
-#include <iostream>
-#include <Userenv.h>
-
-#pragma warning( disable : 4996)
-
-using namespace Aws::Utils;
-namespace Aws
-{
-namespace FileSystem
-{
-
-static const char* FILE_SYSTEM_UTILS_LOG_TAG = "FileSystem";
-
-/**
- * See
- * https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
- * to understand how could we pass long path (over 260 chars) to WinAPI
- */
-static inline Aws::WString ToLongPath(const Aws::WString& path)
-{
- if (path.size() > MAX_PATH - 12/*8.3 file name*/)
- {
- return L"\\\\?\\" + path;
- }
- return path;
-}
-
-class User32Directory : public Directory
-{
-public:
- User32Directory(const Aws::String& path, const Aws::String& relativePath) : Directory(path, relativePath), m_find(INVALID_HANDLE_VALUE), m_lastError(0)
- {
- WIN32_FIND_DATAW ffd;
- AWS_LOGSTREAM_TRACE(FILE_SYSTEM_UTILS_LOG_TAG, "Entering directory " << m_directoryEntry.path);
-
- m_find = FindFirstFileW(ToLongPath(Aws::Utils::StringUtils::ToWString(m_directoryEntry.path.c_str())).c_str(), &ffd);
- if (m_find != INVALID_HANDLE_VALUE)
- {
- m_directoryEntry = ParseFileInfo(ffd, false);
- FindClose(m_find);
- auto seachPath = Join(m_directoryEntry.path, "*");
- m_find = FindFirstFileW(ToLongPath(Aws::Utils::StringUtils::ToWString(seachPath.c_str())).c_str(), &m_ffd);
- }
- else
- {
- AWS_LOGSTREAM_ERROR(FILE_SYSTEM_UTILS_LOG_TAG, "Could not load directory " << m_directoryEntry.path << " with error code " << GetLastError());
- }
- }
-
- ~User32Directory()
- {
- if (m_find != INVALID_HANDLE_VALUE)
- {
- FindClose(m_find);
- }
- }
-
- operator bool() const override { return m_directoryEntry.operator bool() && m_find != INVALID_HANDLE_VALUE; }
-
- DirectoryEntry Next() override
- {
- assert(m_find != INVALID_HANDLE_VALUE);
- DirectoryEntry entry;
- bool invalidEntry = true;
-
- while(invalidEntry && !m_lastError)
- {
- //due to the way the FindFirstFile api works,
- //the first entry will already be loaded by the time we get here.
- entry = ParseFileInfo(m_ffd, true);
-
- Aws::String fileName = Aws::Utils::StringUtils::FromWString(m_ffd.cFileName);
- if (fileName != ".." && fileName != ".")
- {
- AWS_LOGSTREAM_TRACE(FILE_SYSTEM_UTILS_LOG_TAG, "Found entry " << entry.path);
- invalidEntry = false;
- }
- else
- {
- entry.fileType = FileType::None;
- AWS_LOGSTREAM_TRACE(FILE_SYSTEM_UTILS_LOG_TAG, "Skipping . or .. entries.");
- }
-
- if(!FindNextFileW(m_find, &m_ffd))
- {
- m_lastError = GetLastError();
- AWS_LOGSTREAM_ERROR(FILE_SYSTEM_UTILS_LOG_TAG, "Could not fetch next entry from " << m_directoryEntry.path << " with error code " << m_lastError);
- break;
- }
- }
-
- return entry;
- }
-
-private:
- DirectoryEntry ParseFileInfo(WIN32_FIND_DATAW& ffd, bool computePath)
- {
- DirectoryEntry entry;
- LARGE_INTEGER fileSize;
- fileSize.HighPart = ffd.nFileSizeHigh;
- fileSize.LowPart = ffd.nFileSizeLow;
- entry.fileSize = static_cast<int64_t>(fileSize.QuadPart);
-
- if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- {
- entry.fileType = FileType::Directory;
- }
- else
- {
- entry.fileType = FileType::File;
- }
-
- if(computePath)
- {
- entry.path = Join(m_directoryEntry.path, Aws::Utils::StringUtils::FromWString(ffd.cFileName));
- entry.relativePath = m_directoryEntry.relativePath.empty() ? Aws::Utils::StringUtils::FromWString(ffd.cFileName) : Join(m_directoryEntry.relativePath, Aws::Utils::StringUtils::FromWString(ffd.cFileName));
- }
- else
- {
- entry.path = m_directoryEntry.path;
- entry.relativePath = m_directoryEntry.relativePath;
- }
-
- return entry;
- }
-
- HANDLE m_find;
- WIN32_FIND_DATAW m_ffd;
- DWORD m_lastError;
-};
-
-Aws::String GetHomeDirectory()
-{
- static const char* HOME_DIR_ENV_VAR = "USERPROFILE";
-
- AWS_LOGSTREAM_TRACE(FILE_SYSTEM_UTILS_LOG_TAG, "Checking " << HOME_DIR_ENV_VAR << " for the home directory.");
- Aws::String homeDir = Aws::Environment::GetEnv(HOME_DIR_ENV_VAR);
- AWS_LOGSTREAM_DEBUG(FILE_SYSTEM_UTILS_LOG_TAG, "Environment value for variable " << HOME_DIR_ENV_VAR << " is " << homeDir);
- if(homeDir.empty())
- {
- AWS_LOGSTREAM_WARN(FILE_SYSTEM_UTILS_LOG_TAG, "Home dir not stored in environment, trying to fetch manually from the OS.");
- HANDLE hToken;
-
- if (OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &hToken))
- {
- DWORD len = MAX_PATH;
- WCHAR path[MAX_PATH];
- if (GetUserProfileDirectoryW(hToken, path, &len))
- {
- homeDir = Aws::Utils::StringUtils::FromWString(path);
- }
- CloseHandle(hToken);
- }
-
- AWS_LOGSTREAM_INFO(FILE_SYSTEM_UTILS_LOG_TAG, "Pulled " << homeDir << " as home directory from the OS.");
- }
-
- Aws::String retVal = (homeDir.size() > 0) ? Aws::Utils::StringUtils::Trim(homeDir.c_str()) : "";
-
- if (!retVal.empty())
- {
- if (retVal.at(retVal.length() - 1) != Aws::FileSystem::PATH_DELIM)
- {
- retVal += Aws::FileSystem::PATH_DELIM;
- }
- }
-
- return retVal;
-}
-
-Aws::String GetExecutableDirectory()
-{
- static const unsigned long long bufferSize = 256;
- WCHAR buffer[bufferSize];
-
- memset(buffer, 0, sizeof(buffer));
-
- if (GetModuleFileNameW(nullptr, buffer, static_cast<DWORD>(sizeof(buffer))))
- {
- Aws::String bufferStr(Aws::Utils::StringUtils::FromWString(buffer));
- auto fileNameStart = bufferStr.find_last_of(PATH_DELIM);
- if (fileNameStart != std::string::npos)
- {
- bufferStr = bufferStr.substr(0, fileNameStart);
- }
-
- return bufferStr;
- }
-
- return "";
-}
-
-bool CreateDirectoryIfNotExists(const char* path, bool createParentDirs)
-{
- Aws::String directoryName = path;
- AWS_LOGSTREAM_INFO(FILE_SYSTEM_UTILS_LOG_TAG, "Creating directory " << directoryName);
-
- // Create intermediate directories or create the target directory once.
- for (size_t i = createParentDirs ? 0 : directoryName.size() - 1; i < directoryName.size(); i++)
- {
- // Create the intermediate directory if we find a delimiter and the delimiter is not the first char, or if this is the target directory.
- if (i != 0 && (directoryName[i] == FileSystem::PATH_DELIM || i == directoryName.size() - 1))
- {
- // the last delimeter can be removed safely.
- if (directoryName[i] == FileSystem::PATH_DELIM)
- {
- directoryName[i] = '\0';
- }
- if (CreateDirectoryW(ToLongPath(StringUtils::ToWString(directoryName.c_str())).c_str(), nullptr))
- {
- AWS_LOGSTREAM_DEBUG(FILE_SYSTEM_UTILS_LOG_TAG, "Creation of directory " << directoryName.c_str() << " succeeded.");
- }
- else
- {
- DWORD errorCode = GetLastError();
- if (errorCode != ERROR_ALREADY_EXISTS && errorCode != NO_ERROR) // in vs2013 the errorCode is NO_ERROR
- {
- AWS_LOGSTREAM_ERROR(FILE_SYSTEM_UTILS_LOG_TAG, " Creation of directory " << directoryName.c_str() << " returned code: " << errorCode);
- return false;
- }
- AWS_LOGSTREAM_DEBUG(FILE_SYSTEM_UTILS_LOG_TAG, " Creation of directory " << directoryName.c_str() << " returned code: " << errorCode);
- }
- // Restore the path. We are good even if we didn't change that char to '\0', because we are ready to return.
- directoryName[i] = FileSystem::PATH_DELIM;
- }
- }
- return true;
-}
-
-bool RemoveFileIfExists(const char* path)
-{
- AWS_LOGSTREAM_INFO(FILE_SYSTEM_UTILS_LOG_TAG, "Deleting file: " << path);
-
- if (DeleteFileW(ToLongPath(Aws::Utils::StringUtils::ToWString(path)).c_str()))
- {
- AWS_LOGSTREAM_DEBUG(FILE_SYSTEM_UTILS_LOG_TAG, "Successfully deleted file: " << path);
- return true;
- }
- else
- {
- DWORD errorCode = GetLastError();
- AWS_LOGSTREAM_DEBUG(FILE_SYSTEM_UTILS_LOG_TAG, "Deletion of file: " << path << " Returned error code: " << errorCode);
- return errorCode == ERROR_FILE_NOT_FOUND;
- }
-}
-
-bool RelocateFileOrDirectory(const char* from, const char* to)
-{
- AWS_LOGSTREAM_INFO(FILE_SYSTEM_UTILS_LOG_TAG, "Moving file at " << from << " to " << to);
-
- if(MoveFileW(ToLongPath(Aws::Utils::StringUtils::ToWString(from)).c_str(), Aws::Utils::StringUtils::ToWString(to).c_str()))
- {
- AWS_LOGSTREAM_DEBUG(FILE_SYSTEM_UTILS_LOG_TAG, "The moving operation of file at " << from << " to " << to << " Succeeded.");
- return true;
- }
- else
- {
- int errorCode = GetLastError();
- AWS_LOGSTREAM_DEBUG(FILE_SYSTEM_UTILS_LOG_TAG, "The moving operation of file at " << from << " to " << to << " Returned error code of " << errorCode);
- return false;
- }
-}
-
-bool RemoveDirectoryIfExists(const char* path)
-{
- AWS_LOGSTREAM_INFO(FILE_SYSTEM_UTILS_LOG_TAG, "Removing directory at " << path);
-
- if(RemoveDirectoryW(ToLongPath(Aws::Utils::StringUtils::ToWString(path)).c_str()))
- {
- AWS_LOGSTREAM_DEBUG(FILE_SYSTEM_UTILS_LOG_TAG, "The remove operation of file at " << path << " Succeeded.");
- return true;
- }
- else
- {
- int errorCode = GetLastError();
- if (errorCode == ERROR_DIR_NOT_EMPTY)
- {
- AWS_LOGSTREAM_ERROR(FILE_SYSTEM_UTILS_LOG_TAG, "The remove operation of file at " << path << " failed. with error code because it was not empty.");
- }
-
- else if(errorCode == ERROR_DIRECTORY)
- {
- AWS_LOGSTREAM_DEBUG(FILE_SYSTEM_UTILS_LOG_TAG, "The deletion of directory at " << path << " failed because it doesn't exist.");
- return true;
-
- }
-
- AWS_LOGSTREAM_DEBUG(FILE_SYSTEM_UTILS_LOG_TAG, "The remove operation of file at " << path << " failed. with error code " << errorCode);
- return false;
- }
-}
-
-Aws::String CreateTempFilePath()
-{
-#ifdef _MSC_VER
-#pragma warning(disable: 4996) // _CRT_SECURE_NO_WARNINGS
-#endif
- char s_tempName[L_tmpnam_s+1];
-
- /*
- Prior to VS 2014, tmpnam/tmpnam_s generated root level files ("\filename") which were not appropriate for our usage, so for the windows version, we prepended a '.' to make it a
- tempfile in the current directory. Starting with VS2014, the behavior of tmpnam/tmpnam_s was changed to be a full, valid filepath based on the
- current user ("C:\Users\username\AppData\Local\Temp\...").
-
- See the tmpnam section in http://blogs.msdn.com/b/vcblog/archive/2014/06/18/crt-features-fixes-and-breaking-changes-in-visual-studio-14-ctp1.aspx
- for more details.
- */
-
-#if _MSC_VER >= 1900
- tmpnam_s(s_tempName, L_tmpnam_s);
-#else
- s_tempName[0] = '.';
- tmpnam_s(s_tempName + 1, L_tmpnam_s);
-#endif // _MSC_VER
-
-
- return s_tempName;
-}
-
-Aws::UniquePtr<Directory> OpenDirectory(const Aws::String& path, const Aws::String& relativePath)
-{
- return Aws::MakeUnique<User32Directory>(FILE_SYSTEM_UTILS_LOG_TAG, path, relativePath);
-}
-
-} // namespace FileSystem
-} // namespace Aws
diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform/windows/OSVersionInfo.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform/windows/OSVersionInfo.cpp
deleted file mode 100644
index 0180f7fbf6..0000000000
--- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform/windows/OSVersionInfo.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/**
- * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
- * SPDX-License-Identifier: Apache-2.0.
- */
-
-#include <aws/core/platform/OSVersionInfo.h>
-#include <aws/core/utils/StringUtils.h>
-#include <aws/core/utils/memory/stl/AWSStringStream.h>
-
-#include <iomanip>
-
-#pragma warning(disable: 4996)
-#include <windows.h>
-#include <stdio.h>
-namespace Aws
-{
-namespace OSVersionInfo
-{
-
-Aws::String GetSysCommandOutput(const char* command)
-{
- Aws::String outputStr;
- FILE* outputStream;
- const int maxBufferSize = 256;
- char outputBuffer[maxBufferSize];
-
- outputStream = _popen(command, "r");
-
- if (outputStream)
- {
- while (!feof(outputStream))
- {
- if (fgets(outputBuffer, maxBufferSize, outputStream) != nullptr)
- {
- outputStr.append(outputBuffer);
- }
- }
-
- _pclose(outputStream);
-
- return Aws::Utils::StringUtils::Trim(outputStr.c_str());
- }
-
- return {};
-}
-
-Aws::String ComputeOSVersionString()
-{
- // With the release of Windows 8.1, the behavior of the GetVersionEx API has changed in the value it will return for the operating system version.
- // The value returned by the GetVersionEx function now depends on how the application is manifested.
- // https://msdn.microsoft.com/en-us/library/windows/desktop/ms724451%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
- //
- // This only works when the application is manifested for Windows 8.1 or 10, which we don't actually care about.
- // Also, this will cause build headaches for folks not building with VS2015, and is overall an unusable API for us.
- // The following is the least painful but most reliable hack I can come up with.
- //
- // From this article: https://msdn.microsoft.com/en-us/library/windows/desktop/ms724429.aspx
- // we will do the following:
- //
- // To obtain the full version number for the operating system, call the GetFileVersionInfo function on one of the system DLLs, such as Kernel32.dll,
- // then call VerQueryValue to obtain the \\StringFileInfo\\<lang><codepage>\\ProductVersion subblock of the file version information.
- //
- Aws::StringStream ss;
- ss << "Windows/";
-
- DWORD uselessParameter(0);
- static const char* FILE_TO_CHECK = "Kernel32.dll";
- DWORD fileVersionSize = GetFileVersionInfoSizeA(FILE_TO_CHECK, &uselessParameter);
- void* blob = Aws::Malloc("OSVersionInfo", static_cast<size_t>(fileVersionSize));
- bool versionFound(false);
-
- if (GetFileVersionInfoA(FILE_TO_CHECK, 0, fileVersionSize, blob))
- {
- struct LANGANDCODEPAGE {
- WORD wLanguage;
- WORD wCodePage;
- } *lpTranslate;
-
- UINT sizeOfCodePage(0);
-
- if (VerQueryValueA(blob, "\\VarFileInfo\\Translation", (LPVOID*)&lpTranslate, &sizeOfCodePage))
- {
- //we don't actually care which language pack we get, they should all have the same windows version attached.
- Aws::StringStream codePageSS;
- codePageSS << "\\StringFileInfo\\";
- codePageSS << std::setfill('0') << std::setw(4) << std::nouppercase << std::hex << lpTranslate[0].wLanguage;
- codePageSS << std::setfill('0') << std::setw(4) << std::nouppercase << std::hex << lpTranslate[0].wCodePage;
- codePageSS << "\\ProductVersion";
-
- void* subBlock(nullptr);
- UINT subBlockSize(0);
-
- if (VerQueryValueA(blob, codePageSS.str().c_str(), &subBlock, &subBlockSize))
- {
- ss << static_cast<const char*>(subBlock);
- versionFound = true;
- }
- }
- }
-
- Aws::Free(blob);
-
- if (!versionFound)
- {
- ss << "Unknown Version";
- }
-
-
-
- SYSTEM_INFO sysInfo;
- ZeroMemory(&sysInfo, sizeof(SYSTEM_INFO));
- GetSystemInfo(&sysInfo);
-
- switch (sysInfo.wProcessorArchitecture)
- {
- //PROCESSOR_ARCHITECTURE_AMD64
- case 0x09:
- ss << " AMD64";
- break;
- //PROCESSOR_ARCHITECTURE_IA64
- case 0x06:
- ss << " IA64";
- break;
- //PROCESSOR_ARCHITECTURE_INTEL
- case 0x00:
- ss << " x86";
- break;
- default:
- ss << " Unknown Processor Architecture";
- break;
- }
-
- return ss.str();
-}
-
-
-} // namespace OSVersionInfo
-} // namespace Aws
diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform/windows/Security.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform/windows/Security.cpp
deleted file mode 100644
index fbf9a4e679..0000000000
--- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform/windows/Security.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-/**
- * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
- * SPDX-License-Identifier: Apache-2.0.
- */
-
-#include <aws/core/platform/Security.h>
-
-#include <windows.h>
-
-namespace Aws
-{
-namespace Security
-{
-
-void SecureMemClear(unsigned char *data, size_t length)
-{
- SecureZeroMemory(data, length);
-}
-
-} // namespace Security
-} // namespace Aws
diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform/windows/Time.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform/windows/Time.cpp
deleted file mode 100644
index e186d21c81..0000000000
--- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/platform/windows/Time.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
- * SPDX-License-Identifier: Apache-2.0.
- */
-
-#include <aws/core/platform/Time.h>
-
-#include <time.h>
-
-namespace Aws
-{
-namespace Time
-{
-
-time_t TimeGM(struct tm* const t)
-{
- return _mkgmtime(t);
-}
-
-void LocalTime(tm* t, std::time_t time)
-{
- localtime_s(t, &time);
-}
-
-void GMTime(tm* t, std::time_t time)
-{
- gmtime_s(t, &time);
-}
-
-} // namespace Time
-} // namespace Aws