Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions Extension/src/Debugger/configurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* ------------------------------------------------------------------------------------------ */

import * as jsonc from 'comment-json';
import * as fs from 'fs';
import * as glob from 'glob';
import * as os from 'os';
import * as path from 'path';
Expand All @@ -22,8 +21,8 @@ import * as logger from '../logger';
import { PlatformInformation } from '../platform';
import { rsync, scp, ssh } from '../SSH/commands';
import * as Telemetry from '../telemetry';
import { AttachItemsProvider, AttachPicker, RemoteAttachPicker } from './attachToProcess';
import { AttachItem, showQuickPick } from './attachQuickPick';
import { AttachItemsProvider, AttachPicker, RemoteAttachPicker } from './attachToProcess';
import { ConfigMenu, ConfigMode, ConfigSource, CppDebugConfiguration, DebuggerEvent, DebuggerType, DebugType, IConfiguration, IConfigurationSnippet, isDebugLaunchStr, MIConfigurations, PipeTransportConfigurations, TaskStatus, WindowsConfigurations, WSLConfigurations } from './configurations';
import { NativeAttachItemsProviderFactory } from './nativeAttach';
import { Environment, ParsedEnvironmentFile } from './ParsedEnvironmentFile';
Expand Down Expand Up @@ -303,7 +302,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv

// Validate LLDB-MI
if (os.platform() === 'darwin' && // Check for macOS
fs.existsSync(lldb_mi_10_x_path) && // lldb-mi 10.x exists
util.checkFileExistsSync(lldb_mi_10_x_path) && // lldb-mi 10.x exists
(!macOSMIMode || macOSMIMode === 'lldb') &&
!macOSMIDebuggerPath // User did not provide custom lldb-mi
) {
Expand Down Expand Up @@ -657,7 +656,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
];

for (const searchPath of searchPaths) {
if (fs.existsSync(path.join(searchPath, LLDBFramework))) {
if (util.checkDirectoryExistsSync(path.join(searchPath, LLDBFramework))) {
// Found a framework that 'lldb-mi' can use.
return searchPath;
}
Expand Down
4 changes: 2 additions & 2 deletions Extension/src/LanguageServer/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@ export class DefaultClient implements Client {
}

this.rootFolder = workspaceFolder;
this.rootRealPath = this.RootPath ? fs.existsSync(this.RootPath) ? fs.realpathSync(this.RootPath) : this.RootPath : "";
this.rootRealPath = this.RootPath ? util.checkDirectoryExistsSync(this.RootPath) ? fs.realpathSync(this.RootPath) : this.RootPath : "";

this.workspaceStoragePath = util.extensionContext?.storageUri?.fsPath ?? "";
if (this.workspaceStoragePath.length > 0) {
Expand Down Expand Up @@ -1612,7 +1612,7 @@ export class DefaultClient implements Client {
this.currentCaseSensitiveFileSupport = new PersistentWorkspaceState<boolean>("CPP.currentCaseSensitiveFileSupport", false);
let resetDatabase: boolean = false;
const serverModule: string = getLanguageServerFileName();
const exeExists: boolean = fs.existsSync(serverModule);
const exeExists: boolean = util.checkFileExistsSync(serverModule);
if (!exeExists) {
telemetry.logLanguageServerEvent("missingLanguageServerBinary");
throw String('Missing binary at ' + serverModule);
Expand Down
14 changes: 7 additions & 7 deletions Extension/src/LanguageServer/configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export class CppProperties {
// to the language server until the default include paths and frameworks have been sent.

const configFilePath: string = path.join(this.configFolder, "c_cpp_properties.json");
if (this.rootUri !== null && fs.existsSync(configFilePath)) {
if (this.rootUri !== null && util.checkFileExistsSync(configFilePath)) {
this.propertiesFile = vscode.Uri.file(configFilePath);
} else {
this.propertiesFile = null;
Expand Down Expand Up @@ -481,9 +481,9 @@ export class CppProperties {
list.forEach((entry) => {
if (entry !== "vcpkg") {
const pathToCheck: string = path.join(vcpkgRoot, entry);
if (fs.existsSync(pathToCheck)) {
if (util.checkDirectoryExistsSync(pathToCheck)) {
let p: string = path.join(pathToCheck, "include");
if (fs.existsSync(p)) {
if (util.checkDirectoryExistsSync(p)) {
p = p.replace(/\\/g, "/");
p = p.replace(vcpkgRoot, "${vcpkgRoot}");
this.vcpkgIncludes.push(p);
Expand Down Expand Up @@ -1171,7 +1171,7 @@ export class CppProperties {
this.configurationJson.configurations.forEach(c => {
c.compileCommands?.forEach((path: string) => {
const compileCommandsFile: string = this.resolvePath(path);
if (fs.existsSync(compileCommandsFile)) {
if (util.checkFileExistsSync(compileCommandsFile)) {
filePaths.add(compileCommandsFile);
}
});
Expand Down Expand Up @@ -1672,10 +1672,10 @@ export class CppProperties {
if (!isCl && compilerPathAndArgs.compilerPath) {
const compilerPathMayNeedQuotes: boolean = !resolvedCompilerPath.startsWith('"') && resolvedCompilerPath.includes(" ") && compilerPathAndArgs.compilerArgsFromCommandLineInPath.length > 0;
let pathExists: boolean = true;
const existsWithExeAdded: (path: string) => boolean = (path: string) => isWindows && !path.startsWith("/") && fs.existsSync(path + ".exe");
const existsWithExeAdded: (path: string) => boolean = (path: string) => isWindows && !path.startsWith("/") && util.checkFileExistsSync(path + ".exe");

resolvedCompilerPath = compilerPathAndArgs.compilerPath;
if (!fs.existsSync(resolvedCompilerPath)) {
if (!util.checkFileExistsSync(resolvedCompilerPath)) {
if (existsWithExeAdded(resolvedCompilerPath)) {
resolvedCompilerPath += ".exe";
} else {
Expand All @@ -1686,7 +1686,7 @@ export class CppProperties {
} else if (rootUri) {
// Test if it was a relative path.
const absolutePath: string = rootUri.fsPath + path.sep + resolvedCompilerPath;
if (!fs.existsSync(absolutePath)) {
if (!util.checkFileExistsSync(absolutePath)) {
if (existsWithExeAdded(absolutePath)) {
resolvedCompilerPath = absolutePath + ".exe";
} else {
Expand Down
3 changes: 2 additions & 1 deletion Extension/src/LanguageServer/editorConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import * as fs from 'fs';
import { Minimatch } from 'minimatch';
import * as path from 'path';
import * as util from '../common';
import { isWindows } from '../constants';

export const cachedEditorConfigSettings: Map<string, any> = new Map<string, any>();
Expand Down Expand Up @@ -144,7 +145,7 @@ function getEditorConfig(filePath: string): any {
// Traverse from the file's directory to the root directory.
for (; ;) {
const editorConfigPath: string = path.join(currentDir, '.editorconfig');
if (fs.existsSync(editorConfigPath)) {
if (util.checkFileExistsSync(editorConfigPath)) {
const configFileContent: string = fs.readFileSync(editorConfigPath, 'utf-8');
const configData = parseEditorConfigContent(configFileContent);

Expand Down
8 changes: 4 additions & 4 deletions Extension/src/LanguageServer/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
'use strict';

import { execSync } from 'child_process';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import * as semver from 'semver';
import { quote } from 'shell-quote';
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import * as which from 'which';
import * as util from '../common';
import { getCachedClangFormatPath, getCachedClangTidyPath, getExtensionFilePath, getRawSetting, isArray, isArrayOfString, isBoolean, isNumber, isObject, isString, isValidMapping, setCachedClangFormatPath, setCachedClangTidyPath } from '../common';
import { isWindows } from '../constants';
import * as telemetry from '../telemetry';
Expand Down Expand Up @@ -925,7 +925,7 @@ export class CppSettings extends Settings {
let foundEditorConfigWithVcFormatSettings: boolean = false;
const findConfigFile: (parentPath: string) => boolean = (parentPath: string) => {
const editorConfigPath: string = path.join(parentPath, ".editorconfig");
if (fs.existsSync(editorConfigPath)) {
if (util.checkFileExistsSync(editorConfigPath)) {
const editorConfigSettings: any = getEditorConfigSettings(document.uri.fsPath);
const keys: string[] = Object.keys(editorConfigSettings);
for (let i: number = 0; i < keys.length; ++i) {
Expand Down Expand Up @@ -954,11 +954,11 @@ export class CppSettings extends Settings {
}
}
const clangFormatPath1: string = path.join(parentPath, ".clang-format");
if (fs.existsSync(clangFormatPath1)) {
if (util.checkFileExistsSync(clangFormatPath1)) {
return true;
}
const clangFormatPath2: string = path.join(parentPath, "_clang-format");
return fs.existsSync(clangFormatPath2);
return util.checkFileExistsSync(clangFormatPath2);
};
// Scan parent paths to see which we find first, ".clang-format" or ".editorconfig"
const fsPath: string = document.uri.fsPath;
Expand Down
4 changes: 2 additions & 2 deletions Extension/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ export function getVcpkgRoot(): string {
if (!vcpkgRoot && vcpkgRoot !== "") {
vcpkgRoot = "";
// Check for vcpkg instance.
if (fs.existsSync(getVcpkgPathDescriptorFile())) {
if (checkFileExistsSync(getVcpkgPathDescriptorFile())) {
let vcpkgRootTemp: string = fs.readFileSync(getVcpkgPathDescriptorFile()).toString();
vcpkgRootTemp = vcpkgRootTemp.trim();
if (fs.existsSync(vcpkgRootTemp)) {
if (checkDirectoryExistsSync(vcpkgRootTemp)) {
vcpkgRoot = path.join(vcpkgRootTemp, "/installed").replace(/\\/g, "/");
}
}
Expand Down
3 changes: 2 additions & 1 deletion Extension/src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as fs from 'fs';
import * as os from 'os';
import * as plist from 'plist';
import * as nls from 'vscode-nls';
import * as util from './common';
import { LinuxDistribution } from './linuxDistribution';
import * as logger from './logger';
import { SessionState, SupportedWindowsVersions } from './sessionState';
Expand Down Expand Up @@ -68,7 +69,7 @@ export class PlatformInformation {
let productDarwinVersion: string = "";
let errorMessage: string = "";

if (fs.existsSync(DARWIN_SYSTEM_VERSION_PLIST)) {
if (util.checkFileExistsSync(DARWIN_SYSTEM_VERSION_PLIST)) {
const systemVersionPListBuffer: Buffer = fs.readFileSync(DARWIN_SYSTEM_VERSION_PLIST);
const systemVersionData: any = plist.parse(systemVersionPListBuffer.toString());
if (systemVersionData) {
Expand Down
Loading