webmcp

diff framework/env/encode/concat_file_path.lua @ 0:9fdfb27f8e67

Version 1.0.0
author jbe/bsw
date Sun Oct 25 12:00:00 2009 +0100 (2009-10-25)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/framework/env/encode/concat_file_path.lua	Sun Oct 25 12:00:00 2009 +0100
     1.3 @@ -0,0 +1,19 @@
     1.4 +--[[--
     1.5 +path =                    -- string containing a (file) path
     1.6 +encode.concat_file_path(
     1.7 +  element1,               -- first part of the path
     1.8 +  element2,               -- second part of the path
     1.9 +  ...                     -- more parts of the path
    1.10 +)
    1.11 +
    1.12 +This function takes a variable amount of strings as arguments and returns a concatenation with slashes as seperators. Multiple slashes following each other directly are transformed into a single slash.
    1.13 +
    1.14 +--]]--
    1.15 +
    1.16 +function encode.concat_file_path(...)
    1.17 +  return (
    1.18 +    string.gsub(
    1.19 +      table.concat({...}, "/"), "/+", "/"
    1.20 +    )
    1.21 +  )
    1.22 +end

Impressum / About Us