mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-18 20:25:45 +01:00
08e71c732b
* Added new positive integer ns validation helper * `run`, `exec`, and `spawn` verify threads as a positive integer. * `run` terminal command also fails if the provided threadcount is not a positive integer. * Removed some references to .script files in various documentation, and removed some of the NS1 example blocks
49 lines
1.5 KiB
Markdown
49 lines
1.5 KiB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
|
|
[Home](./index.md) > [bitburner](./bitburner.md) > [NS](./bitburner.ns.md) > [fileExists](./bitburner.ns.fileexists.md)
|
|
|
|
## NS.fileExists() method
|
|
|
|
Check if a file exists.
|
|
|
|
**Signature:**
|
|
|
|
```typescript
|
|
fileExists(filename: string, host?: string): boolean;
|
|
```
|
|
|
|
## Parameters
|
|
|
|
| Parameter | Type | Description |
|
|
| --- | --- | --- |
|
|
| filename | string | Filename of file to check. |
|
|
| host | string | _(Optional)_ Host of target server. This is optional. If it is not specified then the function will use the current server as the target server. |
|
|
|
|
**Returns:**
|
|
|
|
boolean
|
|
|
|
True if specified file exists, and false otherwise.
|
|
|
|
## Remarks
|
|
|
|
RAM cost: 0.1 GB
|
|
|
|
Returns a boolean indicating whether the specified file exists on the target server. The filename for scripts is case-sensitive, but for other types of files it is not. For example, fileExists(“brutessh.exe”) will work fine, even though the actual program is named 'BruteSSH.exe'.
|
|
|
|
If the hostname/ip argument is omitted, then the function will search through the current server (the server running the script that calls this function) for the file.
|
|
|
|
\*
|
|
|
|
## Example
|
|
|
|
|
|
```js
|
|
// The function call will return true if the script named foo.js exists on the foodnstuff server, and false otherwise.
|
|
ns.fileExists("foo.js", "foodnstuff");
|
|
|
|
// The function call will return true if the current server contains the FTPCrack.exe program, and false otherwise.
|
|
ns.fileExists("ftpcrack.exe");
|
|
```
|
|
|