mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-11 16:59:29 +01: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;
|
s: String;
|
||||||
fHandle: THANDLE;
|
fHandle: THANDLE;
|
||||||
begin
|
begin
|
||||||
TempFilename:=SysUtils.GetTempFilename(AppendPathDelim(DirectoryName),'tstperm');
|
|
||||||
Result:=false;
|
Result:=false;
|
||||||
|
if not DirPathExists(DirectoryName) then exit;
|
||||||
|
TempFilename:=SysUtils.GetTempFilename(AppendPathDelim(DirectoryName),'tstperm');
|
||||||
fHandle := FileCreateUtf8(TempFileName, fmCreate, 438);
|
fHandle := FileCreateUtf8(TempFileName, fmCreate, 438);
|
||||||
if (THandle(fHandle) <> feInvalidHandle) then
|
if (THandle(fHandle) <> feInvalidHandle) then
|
||||||
begin
|
begin
|
||||||
|
|||||||
@ -851,9 +851,14 @@ var
|
|||||||
var
|
var
|
||||||
CurPath: String;
|
CurPath: String;
|
||||||
begin
|
begin
|
||||||
|
Result:=false;
|
||||||
|
writeln('TryTemporaryPath AAA1 ',Path);
|
||||||
CurPath:=CleanAndExpandDirectory(Path);
|
CurPath:=CleanAndExpandDirectory(Path);
|
||||||
Result:=DirPathExists(CurPath);
|
writeln('TryTemporaryPath AAA2 ',CurPath);
|
||||||
if Result then NewPath:=CurPath;
|
if CurPath='' then exit(false);
|
||||||
|
if not DirectoryIsWritable(CurPath) then exit;
|
||||||
|
NewPath:=CurPath;
|
||||||
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -862,10 +867,11 @@ begin
|
|||||||
inherited DoBeginDoc;
|
inherited DoBeginDoc;
|
||||||
inc(FBeginDocCount);
|
inc(FBeginDocCount);
|
||||||
|
|
||||||
if (not TryTemporaryPath('~/tmp/'))
|
if (not TryTemporaryPath('~/tmp1/'))
|
||||||
and (not TryTemporaryPath('/tmp/'))
|
and (not TryTemporaryPath('/tmp2/'))
|
||||||
and (not TryTemporaryPath('/var/tmp/')) then
|
and (not TryTemporaryPath('/var/tmp/')) then
|
||||||
NewPath:='';
|
NewPath:='';
|
||||||
|
Halt;
|
||||||
|
|
||||||
FOutputFileName := AppendPathDelim(NewPath)+
|
FOutputFileName := AppendPathDelim(NewPath)+
|
||||||
'OutPrinter_'+FormatDateTime('yyyymmmddd-hhnnss',Now);
|
'OutPrinter_'+FormatDateTime('yyyymmmddd-hhnnss',Now);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user