file_find_first

Syntax:

file_find_first(mask, attr);


Argument Description
mask The mask to use for searching.
attr The specific file attribute to look for.


Returns: String


Description

This function will return the name of the first file that satisfies the mask and the attributes. If no such file exists, then an empty string is returned. The mask can contain a path and can contain wildchars, for example 'C:\temp\*.doc'. The attributes give the additional files you want to see, so the normal files are always returned when they satisfy the mask. You can add up the following constants to see the type of files you want (if you do not wish to add any attributes, use 0):


WARNING! This function may not work as you expect due to GameMaker Studio 2 being sandboxed! Please see the section on File System Limits for more information.

NOTE: This function will not work at all on the HTML5 target, and the filter flags will only work on Windows (use 0 for all other platforms).


Example:

if directory_exists("\User Content")
   {
   file = file_find_first("\User Content\*.doc", fa_readonly);
   }

This will check to see if the specified directory exists then, if it does, go there and return the first "read only" doc file found.