Path manipulation: combine path with filename

Relatively often I have to perform the following operation: Given filename F, add path P, but only if F doesn't already contain a path. So:

F: file.txt

P: c:\foo

Result: c:\foo\file.txt

F: c:\bloo\file.txt

P: c:\foo

Result: c:\bloo\file.txt

 

It's relatively awkward to do this succinctly: I use an if/else with a regular expression. A single operation to do it (perhaps by extending path manipulation even further) would be handy. Perhaps with a flag allowing the provided path to always override any given path.

Steve

I would also like to see a general path combine operation.

For example:
Combine(C:\Temp, \myfile.txt) = C:\Temp\myfile.txt
Combine(C:\Temp, \myfile.txt) = C:\Temp\myfile.txt
Combine(C:\Temp, myfile.txt) = C:\Temp\myfile.txt
Combine(C:\Temp, myfile.txt) = C:\Temp\myfile.txt
Combine(, \myfile.txt) = myfile.txt
Combine(, myfile.txt) = \myfile.txt