Garry's Mod Wiki

Revision Difference

file.Read#545737

<function name="Read" parent="file" type="libraryfunc"> <description> Returns the content of a file. <warning>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.</warning> </description> <realm>Shared and Menu</realm> <file line="4-L19">lua/includes/extensions/file.lua</file> <args> <arg name="fileName" type="string">The name of the file.</arg> <arg name="gamePath" type="string">The path to look for the files and directories in. See <page text="this list">File_Search_Paths</page> for a list of valid paths.</arg> <arg name="gamePath" type="string" default="GAME or DATA">The path to look for the files and directories in. If this argument is set to `true` then the path will be `GAME`, otherwise if the argument is `false` or `nil` then the path will be `DATA`. See <page text="this list">File_Search_Paths</page> for a list of valid paths.</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>