Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-06

GetTempDir return impartial path

7 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

silvioprog

Hi.

I trying to use the GetTempDir, but I get only partial result, e.g.:

\xampp\tmp\

Was to be:

C:\xampp\tmp\

How to I get the complete path of temp dir of server (Apache)?

Thx.

ps. Sorry for my english. ^^'

Silvio Cl?cio =============================================== Blog - <silvioprog.com.br> Twitter - <twitter.com/silvioprog> LazSolutions - <code.google.com/p/lazsolutions> Lazarus-BR - <groups.google.com.br/group/lazarus-br?hl=pt-BR> =============================================== ? ?* Conhe?a nosso canal IRC sobre Lazarus: #lazarus-br * ===============================================

Reply by email

silvioprog
to silvioprog

Oops, the correct title is:

"GetTempDir return a partial path".

2011/6/15 silvioprog :

Show quoted text 15 lines
Hi. I trying to use the GetTempDir, but I get only partial result, e.g.: \xampp\tmp\ Was to be: C:\xampp\tmp\ How to I get the complete path of temp dir of server (Apache)? Thx. ps. Sorry for my english. ^^'
Silvio Cl?cio =============================================== Blog - <silvioprog.com.br> Twitter - <twitter.com/silvioprog> LazSolutions - <code.google.com/p/lazsolutions> Lazarus-BR - <groups.google.com.br/group/lazarus-br?hl=pt-BR> =============================================== ? ?* Conhe?a nosso canal IRC sobre Lazarus: #lazarus-br * ===============================================

Reply by email

ABorka
to silvioprog
silvioprog wrote 20 lines
Oops, the correct title is: "GetTempDir return a partial path". 2011/6/15 silvioprog: > Hi. > > I trying to use the GetTempDir, but I get only partial result, e.g.: > > \xampp\tmp\ > > Was to be: > > C:\xampp\tmp\ > > How to I get the complete path of temp dir of server (Apache)? > > Thx. > > ps. Sorry for my english. ^^'

It might be that your TEMP or TMP environment variable does not have the drive letter.

AB

Reply by email

Michael Van Canneyt
to silvioprog: Oops, the correct title is: "GetTempDir return a partial path". 2011/6/15 silvioprog :…
silvioprog wrote 16 lines
Oops, the correct title is: "GetTempDir return a partial path". 2011/6/15 silvioprog : > Hi. > > I trying to use the GetTempDir, but I get only partial result, e.g.: > > \xampp\tmp\ > > Was to be: > > C:\xampp\tmp\ > > How to I get the complete path of temp dir of server (Apache)?

GetTempDir returns the contents of the TEMP or TMP environment variable. If you get one without drive, it is what Apache passes to your CGI program.

You can also use the windows unit GetTempPath function, but that is not portable.

Maybe we can change the windows version of the GetTempDir() function to use GetTempPath instead.

Michael.

Reply by email

ABorka
to Michael Van Canneyt

...<SNIP>...

Show quoted text 12 lines
>> I trying to use the GetTempDir, but I get only partial result, e.g.: >> >> \xampp\tmp\ >> >> Was to be: >> >> C:\xampp\tmp\ >> >> How to I get the complete path of temp dir of server (Apache)? GetTempDir returns the contents of the TEMP or TMP environment variable. If you get one without drive, it is what Apache passes to your CGI program.

...<SNIP>...

Michael.

One note on that:
Apache does not pass the TEMP environment variable to CGI programs automatically, you need to tell it to do that in the Apache configuration file with a

PassEnv TEMP

(passes the TEMP environment variable as it is defined) or

SetEnv TEMP "c:/path/to/tmp/dir"

(sets the TEMP variable with the given value for the CGI program)

AB

Reply by email

silvioprog
to ABorka

Thanks to all. o/

Solved:

function GetTempDirectory: String;
{$IFDEF MSWINDOWS}
var
  VTempFolder: array[0..MAX_PATH] of Char;
{$ENDIF}
begin
{$IFDEF UNIX}
  Result := GetTempDir;
{$ENDIF}
{$IFDEF MSWINDOWS}
  GetTempPath(MAX_PATH, @VTempFolder);
  Result := StrPas(VTempFolder);
{$ENDIF}
end;
Silvio Cl?cio =============================================== Blog - <silvioprog.com.br> Twitter - <twitter.com/silvioprog> LazSolutions - <code.google.com/p/lazsolutions> Lazarus-BR - <groups.google.com.br/group/lazarus-br?hl=pt-BR> =============================================== ? ?* Conhe?a nosso canal IRC sobre Lazarus: #lazarus-br * ===============================================

Reply by email

silvioprog
to Michael Van Canneyt: GetTempDir returns the contents of the TEMP or TMP environment variable. If you get one…

2011/6/15 Michael Van Canneyt :
[...]

Maybe we can change the windows version of the GetTempDir() function to use GetTempPath instead.

Good idea. ^^

Michael.
Silvio Cl?cio =============================================== Blog - <silvioprog.com.br> Twitter - <twitter.com/silvioprog> LazSolutions - <code.google.com/p/lazsolutions> Lazarus-BR - <groups.google.com.br/group/lazarus-br?hl=pt-BR> =============================================== ? ?* Conhe?a nosso canal IRC sobre Lazarus: #lazarus-br * ===============================================

Reply by email