mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-08 11:19:36 +02:00
+ Added Windows-Compatible GetTempFileName to sysutils
git-svn-id: trunk@1031 -
This commit is contained in:
parent
e6d48d0c6a
commit
752ba67635
@ -204,3 +204,24 @@ begin
|
||||
Result:=GetTempFileName('','');
|
||||
end;
|
||||
|
||||
{$ifndef win32}
|
||||
Function GetTempFileName(Dir,Prefix: PChar; uUnique: DWORD; TempFileName: PChar):DWORD;
|
||||
|
||||
Var
|
||||
P,Buf : String;
|
||||
L : Integer;
|
||||
|
||||
begin
|
||||
P:=StrPas(Prefix);
|
||||
if (uUnique<>0) then
|
||||
P:=P+format('%.4x',[uUnique]);
|
||||
Buf:=GetTempFileName(StrPas(Dir),P);
|
||||
L:=Length(Buf);
|
||||
If (L>0) then
|
||||
Move(Buf[1],TempFileName^,L+1);
|
||||
if (uUnique<>0) then
|
||||
result:=uUnique
|
||||
else
|
||||
result:=1;
|
||||
end;
|
||||
{$endif}
|
||||
|
@ -32,6 +32,8 @@ Function GetTempDir(Global : Boolean) : String;
|
||||
Function GetTempDir : String;
|
||||
Function GetTempFileName(Const Dir,Prefix : String) : String;
|
||||
Function GetTempFileName : String;
|
||||
{ For windows compatibility }
|
||||
function GetTempFileName(Dir,Prefix: PChar; uUnique: DWORD; TempFileName: PChar):DWORD;
|
||||
Function GetAppConfigDir(Global : Boolean) : String;
|
||||
Function GetAppConfigFile(Global : Boolean) : String;
|
||||
Function GetAppConfigFile(Global : Boolean; SubDir : Boolean) : String;
|
||||
|
@ -60,6 +60,16 @@ implementation
|
||||
{ Include platform independent implementation part }
|
||||
{$i sysutils.inc}
|
||||
|
||||
Function SysGetTempFileName(lpPathName:LPCSTR; lpPrefixString:LPCSTR; uUnique:UINT; lpTempFileName:LPSTR):UINT; external 'kernel32' name 'GetTempFileNameA';
|
||||
|
||||
function GetTempFileName(Dir,Prefix: PChar; uUnique: DWORD; TempFileName: PChar):DWORD;
|
||||
|
||||
begin
|
||||
Result:=SysGetTempFileName(Dir,Prefix,uUnique,TempFileName);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{ UUID generation. }
|
||||
|
||||
function CoCreateGuid(out guid: TGUID): HResult; stdcall; external 'ole32.dll' name 'CoCreateGuid';
|
||||
|
Loading…
Reference in New Issue
Block a user