#include <shlwapi.h>
#pragma comment(lib, "shlwapi.lib")
TCHAR szDest[MAX_PATH];
TCHAR szDir[MAX_PATH] = TEXT("C:\\MonRep"); // OU TCHAR szDir[MAX_PATH] = TEXT("C:\\MonRep\\");
TCHAR szFile[MAX_PATH] = TEXT("monFichier.txt");
// szDest contiendra "C:\\MonRep\\monFichier.txt", que szDir comporte un \ final ou non.
PathCombine(szDest, szDir, szFile);
Ne pas reproduire l'inefficacité des interprétés donc éviter de produire un appel de fonction et retourner un truc utile si besoin.
__inline char* bnPATHCOMBINE(char *pszDst, char *pszDir, char *pszFl)
{
char *d = pszDst, *c = pszDir;
if(!pszDir[0] || !pszFl[0]) pszDst[0] = 0;
else {
while(*d = *c) {d++; c++;} // PTR d FINIT SUR ZERO FINAL
if(*(d-1) != '\\') *d++ = '\\';
c = pszFl;
while(*d = *c) {d++; c++;}
}
return d; // CHAINAGE DIRECT SI BESOIN SANS REPARCOURS DE LA CHAINE
}
/**
* combinePaths ()
*
* Combiner deux chemins.
*
* @return String : chemin résultant
*/
import java.io.File;
String combinePaths (String parent, String child) {
File file = new File (parent, child);
return file.getPath ();
}