Garry's Mod Wiki

file.IsDir

file.IsDir

boolean file.IsDir( string fileName, string gamePath )

Description

Returns whether the given file is a directory or not.

This will sometimes return false clientside for directories received from the server via a clientside lua file. You can work around this by using file.Find with the path to the directory followed by a wildcard (no trailing forward slash) and see if the directory is inside the returned directories table (see second example).

Issue Tracker: 1038

Arguments

1 string fileName
The file or directory's name.
2 string gamePath
The path to look for the files and directories in. See this list for a list of valid paths.

Returns

1 boolean
true if the given path is a directory or false if it's a file.

Example

Prints if helloworld.txt is a directory.

print( file.IsDir( "helloworld.txt", "DATA" ) )
Output:
false

Example

Workaround for issue #1038.

local _, folders = file.Find( "path/to/dir*", "LUA" ) for _, v in ipairs( folders ) do if v == "dir" then print( "Directory found!" ) break end end

Special Pages


Wikis

?

Render Time: 26ms

DB GetPage 2
Generate Html 5
SaveChanges (1) 9
Render Body 0
Render Sidebar 7