Difference between revisions of "Fs.getName"

From ComputerCraft Wiki
Jump to: navigation, search
(Create page)
 
(Copy description from API page and use type template)
 
(One intermediate revision by one other user not shown)
Line 2: Line 2:
 
{{Function
 
{{Function
 
|name=fs.getName
 
|name=fs.getName
|args=[[string (type)|string]] path
+
|args={{Type|string}} path
 
|api=fs
 
|api=fs
|returns=[[string]] the last path component of the path, or the string "root" if the path refers to the root directory
+
|returns={{Type|string}} the last path component of the path, or "root" if the path refers to the root directory
|desc=Returns the last path component (forward-slash-separated) component of a path (which need not exist)
+
|desc=Gets the final component of a pathname. Pathname components are separated by forward slashes. The path need not exist.
 
|examples=
 
|examples=
 
{{Example
 
{{Example
Line 13: Line 13:
 
}}
 
}}
 
}}
 
}}
 +
 +
[[Category:Lua_Core_Functions]]

Latest revision as of 19:43, 22 April 2013


Grid Redstone.png  Function fs.getName
Gets the final component of a pathname. Pathname components are separated by forward slashes. The path need not exist.
Syntax fs.getName(string path)
Returns string the last path component of the path, or "root" if the path refers to the root directory
Part of ComputerCraft
API fs

Examples

Grid paper.png  Example
Gets the last path component of a file
Code
print(fs.getName("rom/apis/colors"))
Output colors