mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-19 12:29:30 +02:00
lazutils: DirectoryIsWritable: check if directory exists
git-svn-id: trunk@50170 -
This commit is contained in:
parent
5469545ffc
commit
fb15809cef
@ -467,8 +467,9 @@ var
|
||||
s: String;
|
||||
fHandle: THANDLE;
|
||||
begin
|
||||
TempFilename:=SysUtils.GetTempFilename(AppendPathDelim(DirectoryName),'tstperm');
|
||||
Result:=false;
|
||||
if not DirPathExists(DirectoryName) then exit;
|
||||
TempFilename:=SysUtils.GetTempFilename(AppendPathDelim(DirectoryName),'tstperm');
|
||||
fHandle := FileCreateUtf8(TempFileName, fmCreate, 438);
|
||||
if (THandle(fHandle) <> feInvalidHandle) then
|
||||
begin
|
||||
|
@ -851,9 +851,14 @@ var
|
||||
var
|
||||
CurPath: String;
|
||||
begin
|
||||
Result:=false;
|
||||
writeln('TryTemporaryPath AAA1 ',Path);
|
||||
CurPath:=CleanAndExpandDirectory(Path);
|
||||
Result:=DirPathExists(CurPath);
|
||||
if Result then NewPath:=CurPath;
|
||||
writeln('TryTemporaryPath AAA2 ',CurPath);
|
||||
if CurPath='' then exit(false);
|
||||
if not DirectoryIsWritable(CurPath) then exit;
|
||||
NewPath:=CurPath;
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
begin
|
||||
@ -862,10 +867,11 @@ begin
|
||||
inherited DoBeginDoc;
|
||||
inc(FBeginDocCount);
|
||||
|
||||
if (not TryTemporaryPath('~/tmp/'))
|
||||
and (not TryTemporaryPath('/tmp/'))
|
||||
if (not TryTemporaryPath('~/tmp1/'))
|
||||
and (not TryTemporaryPath('/tmp2/'))
|
||||
and (not TryTemporaryPath('/var/tmp/')) then
|
||||
NewPath:='';
|
||||
Halt;
|
||||
|
||||
FOutputFileName := AppendPathDelim(NewPath)+
|
||||
'OutPrinter_'+FormatDateTime('yyyymmmddd-hhnnss',Now);
|
||||
|
Loading…
Reference in New Issue
Block a user