Created
July 10, 2014 09:58
-
-
Save yann2192/1f422c8a8814deb594fd to your computer and use it in GitHub Desktop.
Path manipulation - from : https://code.google.com/p/nativeclient-sdk/source/browse/trunk/src/nacltoons/data/res/path.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
-- Use of this source code is governed by a BSD-style license that can be | |
-- found in the LICENSE file. | |
--- Path manipulation utility functions. | |
local path = {} | |
function path.dirname(filename) | |
while true do | |
if filename == "" or string.sub(filename, -1) == "/" then | |
break | |
end | |
filename = string.sub(filename, 1, -2) | |
end | |
if filename == "" then | |
filename = "." | |
end | |
return filename | |
end | |
function path.join(dirname, basename) | |
if string.sub(dirname, -1) ~= "/" then | |
dirname = dirname .. "/" | |
end | |
return dirname .. basename | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment