Garry's Mod Wiki

Revision Difference

file.Read#518406

<function name="Read" parent="file" type="libraryfunc"> <description> Returns the content of a file. Beware of casing -- some filesystems are case-sensitive. SRCDS on Linux seems to force file/directory creation to lowercase, but will not modify read operations. </description> <realm>Shared and Menu</realm> <file line="4">lua/includes/extensions/file.lua</file> <args> <arg name="fileName" type="string">The name of the file.</arg> <arg name="path" type="string" default="DATA">The path used to look up the file.&#xA;* &quot;GAME&quot; Structured like base folder (garrysmod/), searches all the mounted content (main folder, addons, mounted games etc)&#xA;* &quot;LUA&quot; or &quot;lsv&quot; - All Lua folders (lua/) including gamesmodes and addons&#xA;* &quot;DATA&quot; Data folder (garrysmod/data)&#xA;* &quot;MOD&quot; Strictly the game folder (garrysmod/), ignores mounting.&#xA;&#xA;It can also be a boolean:&#xA;* true = &quot;GAME&quot;&#xA;* false = &quot;DATA&quot;</arg>⤶ <arg name="path" type="string" default="DATA">The path used to look up the file.* "GAME" Structured like base folder (garrysmod/), searches all the mounted content (main folder, addons, mounted games etc)⤶ * "LUA" or "lsv" - All Lua folders (lua/) including gamesmodes and addons⤶ * "DATA" Data folder (garrysmod/data)⤶ * "MOD" Strictly the game folder (garrysmod/), ignores mounting.⤶ ⤶ It can also be a boolean:⤶ * true = "GAME"⤶ * false = "DATA"</arg>⤶ </args> <rets> <ret name="" type="string">The data from the file as a string, or nil if the file isn't found</ret> </rets> </function> <example> <description>Prints out the content of `helloworld.txt`.</description> <code>print( file.Read("helloworld.txt", "DATA") )</code> <output>This is the content!</output> </example>