mirror of
https://github.com/MaskRay/ccls.git
synced 2025-06-14 04:02:16 +00:00
1. Normalize paths in LSP document URIs and project root to forward slash and uppercase drive letters. 2. Normalize paths in compile_commands.json to forward slash and uppercase drive letters. 3. Normalize paths from directory listing to forward slash. (Drive letter should be same as input dir path, which is already uppercase since path of project root dir is normalized) 4. Add llvm::sys::path::convert_to_slash after certain llvm::sys::path and llvm::fs calls.
66 lines
1.7 KiB
C++
66 lines
1.7 KiB
C++
/* 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.
|
|
==============================================================================*/
|
|
|
|
#if defined(_WIN32)
|
|
#include "platform.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include <Windows.h>
|
|
#include <direct.h>
|
|
#include <fcntl.h>
|
|
#include <io.h>
|
|
|
|
#include <sys/stat.h>
|
|
#include <sys/types.h>
|
|
|
|
#include <algorithm>
|
|
#include <cassert>
|
|
#include <string>
|
|
|
|
std::string NormalizePath(const std::string &path) {
|
|
DWORD retval = 0;
|
|
TCHAR buffer[MAX_PATH] = TEXT("");
|
|
TCHAR **lpp_part = {NULL};
|
|
|
|
std::string result;
|
|
retval = GetFullPathName(path.c_str(), MAX_PATH, buffer, lpp_part);
|
|
// fail, return original
|
|
if (retval == 0)
|
|
result = path;
|
|
else
|
|
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() {}
|
|
|
|
std::string GetExternalCommandOutput(const std::vector<std::string> &command,
|
|
std::string_view input) {
|
|
return "";
|
|
}
|
|
|
|
#endif
|