ccls/src/platform_win.cc

54 lines
1.1 KiB
C++
Raw Normal View History

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>
#include <direct.h>
2017-03-25 20:27:28 +00:00
#include <fcntl.h>
#include <io.h>
#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>
#include <thread>
2017-03-19 22:06:22 +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
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)
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(), '\\', '/');
// 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() {}
// TODO Wait for debugger to attach
2018-01-11 02:43:01 +00:00
void TraceMe() {}
void SpawnThread(void *(*fn)(void *), void *arg) {
std::thread(fn, arg).detach();
}
}
2017-03-19 22:06:22 +00:00
#endif