2018-08-21 05:27:52 +00:00
|
|
|
/* Copyright 2017-2018 ccls Authors
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
==============================================================================*/
|
|
|
|
|
2017-03-19 22:06:22 +00:00
|
|
|
#if defined(_WIN32)
|
|
|
|
#include "platform.h"
|
|
|
|
|
2017-03-25 20:27:28 +00:00
|
|
|
#include "utils.h"
|
|
|
|
|
2017-09-22 01:14:57 +00:00
|
|
|
#include <Windows.h>
|
2017-04-18 02:59:48 +00:00
|
|
|
#include <direct.h>
|
2017-03-25 20:27:28 +00:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <io.h>
|
|
|
|
|
2017-04-20 04:57:44 +00:00
|
|
|
#include <sys/stat.h>
|
2017-09-22 01:14:57 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
2017-03-29 06:33:38 +00:00
|
|
|
#include <algorithm>
|
2017-03-19 22:06:22 +00:00
|
|
|
#include <string>
|
2018-10-02 16:34:55 +00:00
|
|
|
#include <thread>
|
2017-03-19 22:06:22 +00:00
|
|
|
|
2018-08-09 17:08:14 +00:00
|
|
|
std::string NormalizePath(const std::string &path) {
|
2017-03-28 05:27:06 +00:00
|
|
|
DWORD retval = 0;
|
|
|
|
TCHAR buffer[MAX_PATH] = TEXT("");
|
2018-08-09 17:08:14 +00:00
|
|
|
TCHAR **lpp_part = {NULL};
|
2017-03-28 05:27:06 +00:00
|
|
|
|
2018-09-11 19:13:54 +00:00
|
|
|
std::string result;
|
2017-03-28 05:27:06 +00:00
|
|
|
retval = GetFullPathName(path.c_str(), MAX_PATH, buffer, lpp_part);
|
|
|
|
// fail, return original
|
|
|
|
if (retval == 0)
|
2018-09-11 19:13:54 +00:00
|
|
|
result = path;
|
|
|
|
else
|
|
|
|
result = buffer;
|
2017-03-28 05:27:06 +00:00
|
|
|
|
2017-03-29 06:33:38 +00:00
|
|
|
std::replace(result.begin(), result.end(), '\\', '/');
|
2018-09-11 19:13:54 +00:00
|
|
|
// Normalize drive letter.
|
|
|
|
if (result.size() > 1 && result[0] >= 'a' && result[0] <= 'z' &&
|
|
|
|
result[1] == ':')
|
|
|
|
result[0] = toupper(result[0]);
|
2017-03-29 06:33:38 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:02:47 +00:00
|
|
|
void FreeUnusedMemory() {}
|
|
|
|
|
2018-01-07 07:42:42 +00:00
|
|
|
// TODO Wait for debugger to attach
|
2018-01-11 02:43:01 +00:00
|
|
|
void TraceMe() {}
|
2018-01-07 07:42:42 +00:00
|
|
|
|
2018-08-09 17:08:14 +00:00
|
|
|
std::string GetExternalCommandOutput(const std::vector<std::string> &command,
|
2018-02-20 00:19:57 +00:00
|
|
|
std::string_view input) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2018-10-02 16:34:55 +00:00
|
|
|
void SpawnThread(void *(*fn)(void *), void *arg) {
|
|
|
|
std::thread(fn, arg).detach();
|
|
|
|
}
|
|
|
|
|
2017-03-19 22:06:22 +00:00
|
|
|
#endif
|