Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 11ca81fc authored by Elliott Hughes's avatar Elliott Hughes Committed by Gerrit Code Review
Browse files

Merge "Remove adb's unused get_my_path for Windows."

parents c70ac57d 16d79c73
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -67,7 +67,6 @@ LIBADB_linux_SRC_FILES := \
    usb_linux.cpp \

LIBADB_windows_SRC_FILES := \
    get_my_path_windows.cpp \
    sysdeps_win32.cpp \
    usb_windows.cpp \

adb/get_my_path_windows.cpp

deleted100644 → 0
+0 −48
Original line number Diff line number Diff line
/*
 * Copyright (C) 2007 The Android Open Source Project
 *
 * 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.
 */

#include "sysdeps.h"

#include <assert.h>
#include <limits.h>
#include <windows.h>

#include <base/macros.h>

#include "adb.h"

// This is not currently called on Windows. Code that only runs on Windows
// should probably deal with UTF-16 WCHAR/wchar_t since Windows APIs natively
// work in that format.
void get_my_path(char *exe, size_t maxLen) {
    WCHAR wexe[MAX_PATH];

    DWORD module_result = GetModuleFileNameW(NULL, wexe, arraysize(wexe));
    if ((module_result == arraysize(wexe)) || (module_result == 0)) {
        // String truncation or other error.
        wexe[0] = '\0';
    }

    // Convert from UTF-16 to UTF-8.
    const std::string exe_str(narrow(wexe));

    if (exe_str.length() + 1 <= maxLen) {
        strcpy(exe, exe_str.c_str());
    } else {
        exe[0] = '\0';
    }
}