mirror of
https://github.com/github/codeql.git
synced 2026-08-01 16:02:57 +02:00
- Add shared/canonicalize/ C++ DLL that resolves Windows paths via GetFinalPathNameByHandleW with a full-path cache (matching C#'s CanonicalPathCache strategy). - Add JNI interface (canonicalize_jni.cpp) for Kotlin/Java consumers. - Add NativeCanonicalizer.java to kotlin-extractor for loading the DLL and exposing a resolve() method. - Call NativeCanonicalizer.resolve() in FileUtil.tryMakeCanonical(). - Add go/extractor/canonicalize package (Windows + non-Windows impls). - Use canonicalize.CanonicalizePath() in go extractor normalizedPath(). - Update Bazel build files for all new targets and deps.
26 lines
663 B
C++
26 lines
663 B
C++
#ifdef _WIN32
|
|
#include <jni.h>
|
|
#include "canonicalize.h"
|
|
|
|
extern "C" {
|
|
|
|
JNIEXPORT jstring JNICALL
|
|
Java_com_semmle_util_files_NativeCanonicalizer_nativeCanonicalizePath(
|
|
JNIEnv *env, jclass cls, jstring jpath) {
|
|
|
|
const jchar* path = env->GetStringChars(jpath, nullptr);
|
|
const wchar_t* result = canonicalize_path_w(reinterpret_cast<const wchar_t*>(path));
|
|
env->ReleaseStringChars(jpath, path);
|
|
|
|
if (result == nullptr) return nullptr;
|
|
|
|
jstring jresult = env->NewString(
|
|
reinterpret_cast<const jchar*>(result),
|
|
static_cast<jsize>(wcslen(result)));
|
|
canonicalize_free_w(result);
|
|
return jresult;
|
|
}
|
|
|
|
} // extern "C"
|
|
#endif
|