Improved GetTempFile

git-svn-id: https://svn.code.sf.net/p/synalist/code/trunk@205 7c85be65-684b-0410-a082-b2ed4fbef004
This commit is contained in:
geby 2017-06-06 13:28:15 +00:00
parent 227656b61a
commit dbaca3710a

View File

@ -1,9 +1,9 @@
{==============================================================================| {==============================================================================|
| Project : Ararat Synapse | 004.015.006 | | Project : Ararat Synapse | 004.015.007 |
|==============================================================================| |==============================================================================|
| Content: support procedures and functions | | Content: support procedures and functions |
|==============================================================================| |==============================================================================|
| Copyright (c)1999-2013, Lukas Gebauer | | Copyright (c)1999-2017, Lukas Gebauer |
| All rights reserved. | | All rights reserved. |
| | | |
| Redistribution and use in source and binary forms, with or without | | Redistribution and use in source and binary forms, with or without |
@ -33,7 +33,7 @@
| DAMAGE. | | DAMAGE. |
|==============================================================================| |==============================================================================|
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).| | The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
| Portions created by Lukas Gebauer are Copyright (c) 1999-2013. | | Portions created by Lukas Gebauer are Copyright (c) 1999-2017. |
| Portions created by Hernan Sanchez are Copyright (c) 2000. | | Portions created by Hernan Sanchez are Copyright (c) 2000. |
| Portions created by Petr Fejfar are Copyright (c)2011-2012. | | Portions created by Petr Fejfar are Copyright (c)2011-2012. |
| All Rights Reserved. | | All Rights Reserved. |
@ -1842,16 +1842,16 @@ begin
{$ELSE} {$ELSE}
if Dir = '' then if Dir = '' then
begin begin
SetLength(Path, MAX_PATH); Path := StringOfChar(#0, MAX_PATH);
x := GetTempPath(Length(Path), PChar(Path)); x := GetTempPath(Length(Path), PChar(Path));
SetLength(Path, x); Path := PChar(Path);
end end
else else
Path := Dir; Path := Dir;
x := Length(Path); x := Length(Path);
if Path[x] <> '\' then if Path[x] <> '\' then
Path := Path + '\'; Path := Path + '\';
SetLength(Result, MAX_PATH + 1); Result := StringOfChar(#0, MAX_PATH);
GetTempFileName(PChar(Path), PChar(Prefix), 0, PChar(Result)); GetTempFileName(PChar(Path), PChar(Prefix), 0, PChar(Result));
Result := PChar(Result); Result := PChar(Result);
SetFileattributes(PChar(Result), GetFileAttributes(PChar(Result)) or FILE_ATTRIBUTE_TEMPORARY); SetFileattributes(PChar(Result), GetFileAttributes(PChar(Result)) or FILE_ATTRIBUTE_TEMPORARY);