mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-25 18:50:56 +02:00
fileExists no longer case sensitive for programs
This commit is contained in:
+13
-15
@@ -1125,21 +1125,19 @@ export const ns: InternalAPI<NSFull> = {
|
||||
const hostname = helpers.string(ctx, "hostname", _hostname);
|
||||
return GetServer(hostname) !== null;
|
||||
},
|
||||
fileExists:
|
||||
(ctx) =>
|
||||
(_filename, _hostname = ctx.workerScript.hostname) => {
|
||||
const filename = helpers.string(ctx, "filename", _filename);
|
||||
const hostname = helpers.string(ctx, "hostname", _hostname);
|
||||
const server = helpers.getServer(ctx, hostname);
|
||||
const path = resolveFilePath(filename, ctx.workerScript.name);
|
||||
if (!path) return false;
|
||||
if (hasScriptExtension(path)) return server.scripts.has(path);
|
||||
if (hasTextExtension(path)) return server.textFiles.has(path);
|
||||
if (hasProgramExtension(path)) return server.programs.includes(path);
|
||||
if (path.endsWith(".lit") || path.endsWith(".msg")) return server.messages.includes(path as any);
|
||||
if (hasContractExtension(path)) return !!server.contracts.find(({ fn }) => fn === path);
|
||||
return false;
|
||||
},
|
||||
fileExists: (ctx) => (_filename, _hostname) => {
|
||||
const filename = helpers.string(ctx, "filename", _filename);
|
||||
const hostname = helpers.string(ctx, "hostname", _hostname ?? ctx.workerScript.hostname);
|
||||
const server = helpers.getServer(ctx, hostname);
|
||||
const path = resolveFilePath(filename, ctx.workerScript.name);
|
||||
if (!path) return false;
|
||||
if (hasScriptExtension(path)) return server.scripts.has(path);
|
||||
if (hasTextExtension(path)) return server.textFiles.has(path);
|
||||
if (path.endsWith(".lit") || path.endsWith(".msg")) return server.messages.includes(path as any);
|
||||
if (hasContractExtension(path)) return !!server.contracts.find(({ fn }) => fn === path);
|
||||
const lowerPath = path.toLowerCase();
|
||||
return server.programs.map((programName) => programName.toLowerCase()).includes(lowerPath);
|
||||
},
|
||||
isRunning:
|
||||
(ctx) =>
|
||||
(fn, hostname, ...scriptArgs) => {
|
||||
|
||||
Reference in New Issue
Block a user