(relatives)
| 17 | const cacheResolve = new Map(); |
| 18 | |
| 19 | function 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 | |
| 63 | const cacheRelative = new Map(); |
| 64 |
no outgoing calls
no test coverage detected