forked from MaskRay/ccls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
platform_win.cc
48 lines (36 loc) · 1008 Bytes
/
platform_win.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright 2017-2018 ccls Authors
// SPDX-License-Identifier: Apache-2.0
#if defined(_WIN32)
#include "platform.hh"
#include "utils.hh"
#include <Windows.h>
#include <direct.h>
#include <fcntl.h>
#include <io.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <algorithm>
#include <string>
#include <thread>
namespace ccls {
std::string normalizePath(llvm::StringRef path) {
TCHAR buffer[MAX_PATH] = TEXT("");
TCHAR **lpp_part = {NULL};
std::string result(path);
if (GetFullPathName(result.c_str(), MAX_PATH, buffer, lpp_part) != 0)
result = buffer;
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]);
return result;
}
void freeUnusedMemory() {}
// TODO Wait for debugger to attach
void traceMe() {}
void spawnThread(void *(*fn)(void *), void *arg) {
std::thread(fn, arg).detach();
}
} // namespace ccls
#endif