Mega Code Archive

 
Categories / Delphi / Functions
 

Use the linux expand function

Title: use the linux expand function? // example of using the linux wordexp function // see: http://www.opengroup.org/onlinepubs/007908799/xsh/wordexp.html // I use it to expand file paths that use the ~/ character instead of /home// function SystemExpandFilePath(aFilePath: string): string; {$IFDEF LINUX} var awordexp_t: wordexp_t; {$ENDIF} begin Result := aFilePath; {$IFDEF LINUX} { Expand the path, i.e. in linux ~ = user home } if LibC.wordexp(PChar(aFilePath), awordexp_t, 0) = 0 then Result := PChar(awordexp_t.we_wordv^); {$ENDIF} end;