MTA:Eir/FileSystem/translator/exists: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
| Line 28: | Line 28: | ||
local fileName = "someFile.txt"; | local fileName = "someFile.txt"; | ||
if not ( resRoot | if not ( resRoot:exists( fileName ) ) then | ||
local fileHandle = resRoot | local fileHandle = resRoot:open( fileName, "wb+" ); | ||
-- Write our watermark! | -- Write our watermark! | ||
fileHandle | fileHandle:write( "this file is legit." ); | ||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Latest revision as of 23:22, 16 January 2022
This function checks whether a specified file exists on a MTA:Eir FileSystem translator.
Syntax
bool translator:exists ( string filePath )
Arguments
- filePath: the path to the file that should exist
Returns
This function returns true if the given path points to a valid file instance on a FileSystem, false otherwise.
Example
Click to collapse [-]
ClientThis snippet checks whether a file exists on the client. Otherwise, the file is created.
-- Attempt to get a link to our resource directory.
local resRoot = fileCreateTranslator( "/" );
if not ( resRoot ) then
outputDebugString( "could not link the resource instance directory" );
return false;
end
-- Check file existence.
local fileName = "someFile.txt";
if not ( resRoot:exists( fileName ) ) then
local fileHandle = resRoot:open( fileName, "wb+" );
-- Write our watermark!
fileHandle:write( "this file is legit." );
end
FileSystem Translator Functions
- open
- exists
- createDir
- chdir
- delete
- copy
- rename
- size
- stat
- relPath
- relPathRoot
- absPath
- absPathRoot
- scanDir
- scanDirEx
- getDirs
- getFiles
- setOutbreakEnabled
- getOutbreakEnabled
- setPathProcessingMode
- getPathProcessingMode