Pastetool #52

URL: , Paste another

def combine(*paths):
    #wisely determine which seperators to use... / or \

    sep = ""
    for path in paths:
        iBS = path.find("/")
        iSL = path.find("\\")    

        if iSL <> -1 or iBS <> -1:
            if iBS <> -1:
                sep = "/"
                break;
            if iSL <> -1:
                sep = "\\"
                break;

    result = ""
    lastI = len(paths)-1
    for i in range(0, len(paths)):
        path = paths[i]
        if i == lastI:
            result += path
        else:            
            if path[len(path) -1 ] == sep:
                result += path 
            else:
                result += path + sep

    return result

Download code

This python code was pasted on September 25, 2009




Protected with advance Anti-SPAM techniques :)
Coded and designed by Fedmich
Follow us on Twitter