lazutils: DirectoryIsWritable: check if directory exists

git-svn-id: trunk@50170 -
This commit is contained in:
mattias 2015-10-26 09:26:44 +00:00
parent 5469545ffc
commit fb15809cef
2 changed files with 12 additions and 5 deletions

View File

@ -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

View File

@ -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);