Skip to content

Commit

Permalink
Add parseLdconf
Browse files Browse the repository at this point in the history
  • Loading branch information
impactaky committed Jan 17, 2024
1 parent 349dd97 commit 9046f83
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions mimic-cross.deno/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,22 @@ export async function getElfArch(
return;
}
}

export async function parseLdconf(filePath: PathRefLike): Promise<string[]> {
const pathRef = $.path(filePath);
const text = await pathRef.readText();
const ldconfDirs: string[] = [];
for (const line of text.split("\n")) {
if (line.startsWith("#")) continue;
if (line.startsWith("include ")) {
const included = line.slice("include ".length).trim();
for await (const entry of pathRef.expandGlob(included)) {
ldconfDirs.push(...(await parseLdconf(entry.path)));
}
continue;
}
if (line.trim() === "") continue;
ldconfDirs.push(line.trim());
}
return ldconfDirs;
}

0 comments on commit 9046f83

Please sign in to comment.