forked from Mr-Bossman/vscode-clang-format
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
117 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
import vscode = require('vscode'); | ||
|
||
export const CLANG_MODE: vscode.DocumentFilter = { language: 'cpp', scheme: 'file' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
'use strict'; | ||
|
||
import fs = require('fs'); | ||
import path = require('path'); | ||
|
||
var binPathCache: { [bin: string]: string; } = {} | ||
|
||
export function getBinPath(binname: string) { | ||
binname = correctBinname(binname); | ||
if (binPathCache[binname]) return binPathCache[binname]; | ||
|
||
if (process.env["PATH"]) { | ||
var pathparts = process.env["PATH"].split(path.delimiter); | ||
for (var i = 0; i < pathparts.length; i++) { | ||
let binpath = path.join(pathparts[i], binname); | ||
if (fs.existsSync(binpath)) { | ||
binPathCache[binname] = binpath; | ||
return binpath; | ||
} | ||
} | ||
} | ||
|
||
// Else return the binary name directly (this will likely always fail downstream) | ||
binPathCache[binname] = binname; | ||
return binname; | ||
} | ||
|
||
function correctBinname(binname: string) { | ||
if (process.platform === 'win32') | ||
return binname + ".exe"; | ||
else | ||
return binname | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters