Difference between revisions of "love.filesystem.getInfo"

m
m
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{newin|[[0.11.0]]|110|type=function|text=This function replaces [[love.filesystem.exists]], [[love.filesystem.isFile|isFile]], [[love.filesystem.isDirectory|isDirectory]], [[love.filesystem.isSymlink|isSymlink]], [[love.filesystem.getLastModified|getLastModified]], and [[love.filesystem.getSize|getSize]]}}
+
{{newin|[[11.0]]|110|type=function|text=This function replaces [[love.filesystem.exists]], [[love.filesystem.isFile|isFile]], [[love.filesystem.isDirectory|isDirectory]], [[love.filesystem.isSymlink|isSymlink]], [[love.filesystem.getLastModified|getLastModified]], and [[love.filesystem.getSize|getSize]]}}
 
Gets information about the specified file or directory.
 
Gets information about the specified file or directory.
  
Line 5: Line 5:
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
info = love.filesystem.getInfo( path )
+
info = love.filesystem.getInfo( path, filtertype )
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
 
{{param|string|path|The file or directory path to check.}}
 
{{param|string|path|The file or directory path to check.}}
 +
{{param|FileType|filtertype (nil)|If supplied, this parameter causes getInfo to only return the info table if the item at the given path matches the specified file type.}}
 
=== Returns ===
 
=== Returns ===
 
{{param|table|info (nil)|A table containing information about the specified path, or nil if nothing exists at the path. The table contains the following fields:}}
 
{{param|table|info (nil)|A table containing information about the specified path, or nil if nothing exists at the path. The table contains the following fields:}}
Line 23: Line 24:
 
=== Arguments ===
 
=== Arguments ===
 
{{param|string|path|The file or directory path to check.}}
 
{{param|string|path|The file or directory path to check.}}
 +
{{param|table|info|A table which will be filled in with info about the specified path.}}
 +
=== Returns ===
 +
{{param|table|info (nil)|The table given as an argument, or nil if nothing exists at the path. The table will be filled in with the following fields:}}
 +
{{subparam|FileType|type|The type of the object at the path (file, directory, symlink, etc.)}}
 +
{{subparam|number|size (nil)|The size in bytes of the file, or nil if it can't be determined.}}
 +
{{subparam|number|modtime (nil)|The file's last modification time in seconds since the unix epoch, or nil if it can't be determined.}}
 +
 +
== Function ==
 +
This variant only returns info if the item at the given path is the same file type as specified in the filtertype argument, and accepts an existing table to fill in, instead of creating a new one.
 +
=== Synopsis ===
 +
<source lang="lua">
 +
info = love.filesystem.getInfo( path, filtertype, info )
 +
</source>
 +
=== Arguments ===
 +
{{param|string|path|The file or directory path to check.}}
 +
{{param|FileType|filtertype|Causes getInfo to only return the info table if the item at the given path matches the specified file type.}}
 
{{param|table|info|A table which will be filled in with info about the specified path.}}
 
{{param|table|info|A table which will be filled in with info about the specified path.}}
 
=== Returns ===
 
=== Returns ===

Latest revision as of 02:39, 5 April 2018

Available since LÖVE 11.0
This function replaces love.filesystem.exists, isFile, isDirectory, isSymlink, getLastModified, and getSize.

Gets information about the specified file or directory.

Function

Synopsis

info = love.filesystem.getInfo( path, filtertype )

Arguments

string path
The file or directory path to check.
FileType filtertype (nil)
If supplied, this parameter causes getInfo to only return the info table if the item at the given path matches the specified file type.

Returns

table info (nil)
A table containing information about the specified path, or nil if nothing exists at the path. The table contains the following fields:
FileType type
The type of the object at the path (file, directory, symlink, etc.)
number size (nil)
The size in bytes of the file, or nil if it can't be determined.
number modtime (nil)
The file's last modification time in seconds since the unix epoch, or nil if it can't be determined.

Function

This variant accepts an existing table to fill in, instead of creating a new one.

Synopsis

info = love.filesystem.getInfo( path, info )

Arguments

string path
The file or directory path to check.
table info
A table which will be filled in with info about the specified path.

Returns

table info (nil)
The table given as an argument, or nil if nothing exists at the path. The table will be filled in with the following fields:
FileType type
The type of the object at the path (file, directory, symlink, etc.)
number size (nil)
The size in bytes of the file, or nil if it can't be determined.
number modtime (nil)
The file's last modification time in seconds since the unix epoch, or nil if it can't be determined.

Function

This variant only returns info if the item at the given path is the same file type as specified in the filtertype argument, and accepts an existing table to fill in, instead of creating a new one.

Synopsis

info = love.filesystem.getInfo( path, filtertype, info )

Arguments

string path
The file or directory path to check.
FileType filtertype
Causes getInfo to only return the info table if the item at the given path matches the specified file type.
table info
A table which will be filled in with info about the specified path.

Returns

table info (nil)
The table given as an argument, or nil if nothing exists at the path. The table will be filled in with the following fields:
FileType type
The type of the object at the path (file, directory, symlink, etc.)
number size (nil)
The size in bytes of the file, or nil if it can't be determined.
number modtime (nil)
The file's last modification time in seconds since the unix epoch, or nil if it can't be determined.

See Also

Other Languages