MCPcopy Create free account
hub / github.com/Marus/cortex-debug / replaceProgInPath

Function replaceProgInPath

src/backend/symbols.ts:87–100  ·  view source on GitHub ↗
(filepath: string, search: string | RegExp, replace: string)

Source from the content-addressed store, hash-verified

85// Replace last part of the path containing a program to another. If search string not found
86// or replacement the same as search string, then null is returned
87function replaceProgInPath(filepath: string, search: string | RegExp, replace: string): string {
88 if (os.platform() === 'win32') {
89 filepath = filepath.toLowerCase().replace(/\\/g, '/');
90 }
91 const ix = filepath.lastIndexOf('/');
92 const prefix = (ix >= 0) ? filepath.substring(0, ix + 1) : '' ;
93 const suffix = filepath.substring(ix + 1);
94 const replaced = suffix.replace(search, replace);
95 if (replaced === suffix) {
96 return null;
97 }
98 const ret = prefix + replaced;
99 return ret;
100}
101
102const trace = true;
103

Callers 2

constructorMethod · 0.85
loadFromObjdumpAndNmMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected