2018-08-21 05:27:52 +00:00
|
|
|
// Copyright 2017-2018 ccls Authors
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2017-03-19 22:06:22 +00:00
|
|
|
#if defined(_WIN32)
|
2018-10-29 04:21:21 +00:00
|
|
|
#include "platform.hh"
|
2017-03-19 22:06:22 +00:00
|
|
|
|
2018-10-29 04:21:21 +00:00
|
|
|
#include "utils.hh"
|
2017-03-25 20:27:28 +00:00
|
|
|
|
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-12-14 04:13:35 +00:00
|
|
|
namespace ccls {
|
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-10-02 16:34:55 +00:00
|
|
|
void SpawnThread(void *(*fn)(void *), void *arg) {
|
|
|
|
std::thread(fn, arg).detach();
|
|
|
|
}
|
2018-12-14 04:13:35 +00:00
|
|
|
}
|
2018-10-02 16:34:55 +00:00
|
|
|
|
2017-03-19 22:06:22 +00:00
|
|
|
#endif
|