| 64 | type VcpkgDatabase = Record<string, string[]>; // Stored as <header file entry> -> [<port name>] |
| 65 | let vcpkgDbPromise: Promise<VcpkgDatabase>; |
| 66 | async function initVcpkgDatabase(): Promise<VcpkgDatabase> { |
| 67 | const database: VcpkgDatabase = {}; |
| 68 | try { |
| 69 | const zip = new StreamZip.async({ file: util.getExtensionFilePath('VCPkgHeadersDatabase.zip') }); |
| 70 | try { |
| 71 | const data = await zip.entryData('VCPkgHeadersDatabase.txt'); |
| 72 | const lines = data.toString().split('\n'); |
| 73 | lines.forEach(line => { |
| 74 | const portFilePair: string[] = line.split(':'); |
| 75 | if (portFilePair.length !== 2) { |
| 76 | return; |
| 77 | } |
| 78 | |
| 79 | const portName: string = portFilePair[0]; |
| 80 | const relativeHeader: string = portFilePair[1].trimEnd(); |
| 81 | |
| 82 | if (!database[relativeHeader]) { |
| 83 | database[relativeHeader] = []; |
| 84 | } |
| 85 | |
| 86 | database[relativeHeader].push(portName); |
| 87 | }); |
| 88 | } catch { |
| 89 | console.log("Unable to parse vcpkg database file."); |
| 90 | } |
| 91 | await zip.close(); |
| 92 | } catch { |
| 93 | console.log("Unable to open vcpkg database file."); |
| 94 | } |
| 95 | return database; |
| 96 | } |
| 97 | |
| 98 | function getVcpkgHelpAction(): vscode.CodeAction { |
| 99 | const dummy: any[] = [{}]; // To distinguish between entry from CodeActions and the command palette |