<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/wiki/Modules/FileSystem/Porting_Between_Clientside_and_Serverside?action=history&amp;feed=atom</id>
	<title>Modules/FileSystem/Porting Between Clientside and Serverside - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/wiki/Modules/FileSystem/Porting_Between_Clientside_and_Serverside?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Modules/FileSystem/Porting_Between_Clientside_and_Serverside&amp;action=history"/>
	<updated>2026-05-18T15:27:03Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Modules/FileSystem/Porting_Between_Clientside_and_Serverside&amp;diff=38800&amp;oldid=prev</id>
		<title>The GTA: Created page with &quot;There are common issues when wanting to port FileSystem code between clientside and serverside environments. This article should help you avoid pitfalls an...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Modules/FileSystem/Porting_Between_Clientside_and_Serverside&amp;diff=38800&amp;oldid=prev"/>
		<updated>2014-02-02T21:25:01Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;There are common issues when wanting to port &lt;a href=&quot;/wiki/Modules/FileSystem&quot; title=&quot;Modules/FileSystem&quot;&gt;FileSystem&lt;/a&gt; code between clientside and serverside environments. This article should help you avoid pitfalls an...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;There are common issues when wanting to port [[Modules/FileSystem|FileSystem]] code between clientside and serverside environments. This article should help you avoid pitfalls and getting stuck. Since the issues are mostly about lower-level functionality - with a good abstraction layer - you will not have to rewrite much logic.&lt;br /&gt;
&lt;br /&gt;
==There is No 'This Resource' Directory serverside==&lt;br /&gt;
While the [[MTA:Eir]] client exposes a secure API that bases translator creation around resource folders, the FileSystem module '''cannot do that'''. The reason is very technical. Hence if you want to get the resource directory you are ''operating'' in, you need to '''hardcode''' it.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Create a translator in our resource directory.&lt;br /&gt;
local resRoot = fsys.createTranslator( &amp;quot;mods/deathmatch/resources/thisResource/&amp;quot; ); -- thisResource shall be the name of the running resource.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Serverside Translator Abstraction API==&lt;br /&gt;
Once the location of the resource is known and a translator is established, then the creation of translators can be abstracted to the resource directory in a similar way as on the MTA:Eir client. This allows creation of translators that are relative to the resources in a secure way.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function fileCreateTranslator( path )&lt;br /&gt;
    -- Get an absolute path relative to the resource instance directory.&lt;br /&gt;
    local absTransPath = resRoot.absPathRoot( path );&lt;br /&gt;
&lt;br /&gt;
    -- It fails if it tries to up-root.&lt;br /&gt;
    if not ( absTransPath ) then&lt;br /&gt;
        return false;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Create a new translator and return it.&lt;br /&gt;
    return fsys.createTranslator( absTransPath );&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>The GTA</name></author>
	</entry>
</feed>