MTA:Eir/FileSystem/translator/relPath

From Multi Theft Auto: Wiki
Revision as of 23:26, 16 January 2022 by Quiret (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This function transform a path that is passed to it into a path that is relative to the translators current directory. The path must be accessible from the translator. The path can either be absolute or relative.

Syntax

string translator:relPath ( string path )

Arguments

  • path: the path that should be transformed into a relative path; can be nil if the current directory should be returned

Returns

This function returns the relative version of the path that is passed to it, false if the specified path is not accessible by the translator.

Example

Click to collapse [-]
Client

This snippet converts the path relative from one translator to a relative path from another translator.

local function getPathTranslatorRelative( srcTranslator, dstTranslator, srcPath )
    -- Get the absolute path from the srcTranslator perspective.
    local absPath = srcTranslator:absPath( srcPath );

    -- Return the relative path from the dstTranslator. Will return false if conversion cannot happen.
    return dstTranslator:relPath( absPath );
end

FileSystem Translator Functions