file.Find
From GMod Wiki
Revision as of 11:11, 15 October 2011 by TheFreeman193 (Talk | contribs)
Function | |
Syntax |
file.Find( String filename, [ Boolean usebasefolder ] ) Where is this used? |
Description: | |
Find a list of files within a directory | |
Returns: | Table : String Filenames |
Part of Library: | File |
Realm: | |
BBCode Link: | [b][url=http://wiki.garrysmod.com/?title=File.Find]File.Find [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Examples
Description | This example lists all of the text files in the my_mod directory |
---|---|
Used on | |
Code | local list = file.Find("my_mod/*.txt") for _, f in pairs(list) do Msg( f ) end |
Output | N/A |
Additional Notes
- Relative to garrysmod/data.
- If usebasefolder is true then it starts relative to the GMod base folder (garrysmod/garrysmod).
- file.Find lists all files and folders, not just files.
- file.Find returns the file name as the value, NOT the full path. So for example, if you had something like data/random/stuff.txt:
MsgAll(file.Find("random/stuff.txt")[1]) //Output: stuff.txt MsgAll(file.Find("random/*")[1]) //Output: stuff.txt MsgAll(file.Find("random/*.txt")[1]) //Output: stuff.txt