mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 09:33:49 +01:00
30 lines
1.2 KiB
ReStructuredText
30 lines
1.2 KiB
ReStructuredText
fileExists() Netscript Function
|
|
===============================
|
|
|
|
.. js:function:: fileExists(filename[, hostname = current hostname])
|
|
|
|
:RAM cost: 0.1 GB
|
|
|
|
:param string filename: Filename of file to check.
|
|
:param string hostname:
|
|
Hostname of target server. This is optional. If it is not specified then
|
|
the function will use the current server as the target server.
|
|
:returns: ``true`` if the file exists.
|
|
|
|
The filename for scripts and .txt files 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`` argument is omitted, then the function will search
|
|
through the server running the script that calls this function for the file.
|
|
|
|
Examples:
|
|
|
|
.. code-block:: javascript
|
|
|
|
ns.fileExists("foo.js", "foodnstuff"); // returns: false
|
|
ns.fileExists("ftpcrack.exe"); // returns: true
|
|
|
|
The first example above will return true if the script named ``foo.js`` exists on the ``foodnstuff`` server, and false otherwise.
|
|
The second example above will return true if the current server contains the ``FTPCrack.exe`` program, and false otherwise.
|