Merged in tbasnoopy/premake-dev/extension replace (pull request #148)
add replaceextension function for paths
This commit is contained in:
commit
34bf41ea9d
@ -27,3 +27,4 @@ Since 5.0-alpha1:
|
|||||||
* Embedded scripts now compressed with LuaSrcDiet (Oliver Schneider)
|
* Embedded scripts now compressed with LuaSrcDiet (Oliver Schneider)
|
||||||
* Checks to prevent self-linking (Mark Chandler)
|
* Checks to prevent self-linking (Mark Chandler)
|
||||||
* os.rmdir() can now removes dotted subdirectories (Alexey Orlov)
|
* os.rmdir() can now removes dotted subdirectories (Alexey Orlov)
|
||||||
|
* Added path.replaceextension() (M Skibbe)
|
||||||
|
@ -23,6 +23,8 @@ Patch contributors:
|
|||||||
* Prevent self-linking
|
* Prevent self-linking
|
||||||
Mihai Sebea <http://twitter.com/mihai_sebea>
|
Mihai Sebea <http://twitter.com/mihai_sebea>
|
||||||
* Xcode exporter fixes and improvements
|
* Xcode exporter fixes and improvements
|
||||||
|
M Skibbe
|
||||||
|
* path.replaceextension()
|
||||||
Oliver Schneider
|
Oliver Schneider
|
||||||
* compress embedded scripts with LuaSrcDiet
|
* compress embedded scripts with LuaSrcDiet
|
||||||
Renaud Guillard <https://bitbucket.org/noresources>
|
Renaud Guillard <https://bitbucket.org/noresources>
|
||||||
|
@ -210,6 +210,27 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Replace the file extension.
|
||||||
|
--
|
||||||
|
|
||||||
|
function path.replaceextension(p, newext)
|
||||||
|
local ext = path.getextension(p)
|
||||||
|
|
||||||
|
if not ext then
|
||||||
|
return p
|
||||||
|
end
|
||||||
|
|
||||||
|
if not newext:findlast(".", true) then
|
||||||
|
newext = "."..newext
|
||||||
|
end
|
||||||
|
|
||||||
|
return p:match("^(.*)"..ext.."$")..newext
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Converts from a simple wildcard syntax, where * is "match any"
|
-- Converts from a simple wildcard syntax, where * is "match any"
|
||||||
-- and ** is "match recursive", to the corresponding Lua pattern.
|
-- and ** is "match recursive", to the corresponding Lua pattern.
|
||||||
|
@ -298,6 +298,32 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- path.replaceextension() tests
|
||||||
|
--
|
||||||
|
|
||||||
|
function suite.getabsolute_replaceExtension()
|
||||||
|
test.isequal("/AB.foo", path.replaceextension("/AB.exe","foo"))
|
||||||
|
end
|
||||||
|
|
||||||
|
function suite.getabsolute_replaceExtensionWithDot()
|
||||||
|
test.isequal("/AB.foo", path.replaceextension("/AB.exe",".foo"))
|
||||||
|
end
|
||||||
|
|
||||||
|
function suite.getabsolute_replaceExtensionWithDotMultipleDots()
|
||||||
|
test.isequal("/nunit.framework.foo", path.replaceextension("/nunit.framework.dll",".foo"))
|
||||||
|
end
|
||||||
|
|
||||||
|
function suite.getabsolute_replaceExtensionCompletePath()
|
||||||
|
test.isequal("/nunit/framework/main.foo", path.replaceextension("/nunit/framework/main.cpp",".foo"))
|
||||||
|
end
|
||||||
|
|
||||||
|
function suite.getabsolute_replaceExtensionWithoutExtension()
|
||||||
|
test.isequal("/nunit/framework/main.foo", path.replaceextension("/nunit/framework/main",".foo"))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- path.translate() tests
|
-- path.translate() tests
|
||||||
--
|
--
|
||||||
|
Loading…
Reference in New Issue
Block a user