Permalink
Browse files

Fixed string.GetFileFromFilename

Fixed a case where giving it a filename would result in a empty string
  • Loading branch information...
robotboy655 committed Feb 9, 2017
1 parent bee84c0 commit eef8c2b95baa2928a2cf88b40f5a0468aac26519
Showing with 1 addition and 5 deletions.
  1. +1 −5 garrysmod/lua/includes/extensions/string.lua
@@ -65,9 +65,7 @@ local pattern_escape_replacements = {
}
function string.PatternSafe( str )
return ( str:gsub( ".", pattern_escape_replacements ) )
end
--[[---------------------------------------------------------
@@ -124,11 +122,9 @@ end
Name: StripExtension( path )
-----------------------------------------------------------]]
function string.StripExtension( path )
local i = path:match( ".+()%.%w+$" )
if ( i ) then return path:sub( 1, i - 1 ) end
return path
end
--[[---------------------------------------------------------
@@ -146,6 +142,7 @@ end
Usage: string.GetFileFromFilename("garrysmod/lua/modules/string.lua")
-----------------------------------------------------------]]
function string.GetFileFromFilename( path )
if ( !path:find( "\\" ) && !path:find( "/" ) ) then return path end
return path:match( "[\\/]([^/\\]+)$" ) or ""
end
@@ -160,7 +157,6 @@ end
string.FormattedTime( 123.456, "%2i:%02i") ==> " 2:03"
string.FormattedTime( 123.456 ) ==> { h = 0, m = 2, s = 3, ms = 45 }
-------------------------------------------------------------------]]
function string.FormattedTime( seconds, format )
if ( not seconds ) then seconds = 0 end
local hours = math.floor( seconds / 3600 )

0 comments on commit eef8c2b

Please sign in to comment.