MCPcopy
hub / github.com/ollm/OpenComic / resolve

Function resolve

scripts/relative.js:19–61  ·  view source on GitHub ↗
(relatives)

Source from the content-addressed store, hash-verified

17const cacheResolve = new Map();
18
19function resolve(relatives)
20{
21 if(!relatives || !relatives.includes('|||||'))
22 return relatives;
23
24 if(cacheResolve.has(relatives))
25 return cacheResolve.get(relatives);
26
27 const paths = relatives.split('|||||');
28
29 let path = '';
30 let exists = false;
31
32 for(let i = 0, len = paths.length; i < len; i++)
33 {
34 path = p.resolve(base.path, paths[i]);
35
36 if(fs.existsSync(path))
37 {
38 exists = true;
39 break;
40 }
41 }
42
43 // Check if file exists in the same disk as OpenComic
44 if(!exists && base.disk)
45 {
46 const sameDisk = path.replace(/^([A-Za-z]):/, base.disk+':');
47
48 if(sameDisk !== path && fs.existsSync(path))
49 {
50 exists = true;
51 path = sameDisk;
52 }
53 }
54
55 if(exists)
56 cacheRelative.set(path, relatives);
57
58 cacheResolve.set(relatives, path);
59
60 return path;
61}
62
63const cacheRelative = new Map();
64

Callers 15

processTheImageQueueFunction · 0.85
clientFunction · 0.85
getFunction · 0.85
rawToPngFunction · 0.85
rawToBufferFunction · 0.85
loadImageFunction · 0.85
ebookFunction · 0.85
loadShoShoFunction · 0.85
loadPdfjsFunction · 0.85
loadPdfjsDecodersFunction · 0.85
loadJxlImageFunction · 0.85
loadFoliateJsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected