lcl, codetools: don't request exclusive rights when IDE reads/writes units

git-svn-id: trunk@18251 -
This commit is contained in:
paul 2009-01-11 08:30:43 +00:00
parent 133caf74fd
commit 7467771ed0
2 changed files with 27 additions and 23 deletions

View File

@ -657,25 +657,26 @@ begin
end; end;
function TSourceLog.LoadFromFile(const Filename: string): boolean; function TSourceLog.LoadFromFile(const Filename: string): boolean;
var s: string; var
s: string;
fs: TFileStream; fs: TFileStream;
begin begin
Result:=true; Result := True;
try try
fs:=TFileStream.Create(UTF8ToSys(Filename), fmOpenRead); fs := TFileStream.Create(UTF8ToSys(Filename), fmOpenRead or fmShareDenyNone);
try try
SetLength(s,fs.Size); SetLength(s, fs.Size);
if s<>'' then if s <> '' then
fs.Read(s[1],length(s)); fs.Read(s[1], length(s));
FDiskEncoding:=''; FDiskEncoding := '';
FMemEncoding:=''; FMemEncoding := '';
DecodeLoaded(Filename,s,FDiskEncoding,FMemEncoding); DecodeLoaded(Filename, s, FDiskEncoding, FMemEncoding);
Source:=s; Source := s;
finally finally
fs.Free; fs.Free;
end; end;
except except
Result:=false; Result := False;
end; end;
end; end;
@ -695,22 +696,25 @@ var
s: String; s: String;
begin begin
//DebugLn('TSourceLog.SaveToFile Self=',DbgS(Self)); //DebugLn('TSourceLog.SaveToFile Self=',DbgS(Self));
Result:=true; Result := True;
try try
InvalidateFileStateCache; InvalidateFileStateCache;
// keep filename case on disk // keep filename case on disk
TheFilename:=FindDiskFilename(Filename); TheFilename := FindDiskFilename(Filename);
fs:=TFileStream.Create(UTF8ToSys(TheFilename), fmCreate); if FileExistsUTF8(TheFilename) then
fs := TFileStream.Create(UTF8ToSys(TheFilename), fmOpenWrite or fmShareDenyNone)
else
fs := TFileStream.Create(UTF8ToSys(TheFilename), fmCreate);
try try
s:=Source; s := Source;
EncodeSaving(Filename,s); EncodeSaving(Filename, s);
if s<>'' then if s <> '' then
fs.Write(s[1],length(s)); fs.Write(s[1], length(s));
finally finally
fs.Free; fs.Free;
end; end;
except except
Result:=false; Result := False;
end; end;
end; end;

View File

@ -723,9 +723,9 @@ begin
if FileReadable then ; if FileReadable then ;
end; end;
function FileIsText(const AFilename: string; out FileReadable: boolean function FileIsText(const AFilename: string; out FileReadable: boolean): boolean;
): boolean; var
var fs: TFileStream; fs: TFileStream;
Buf: string; Buf: string;
Len, i: integer; Len, i: integer;
NewLine: boolean; NewLine: boolean;
@ -734,7 +734,7 @@ begin
Result:=false; Result:=false;
FileReadable:=true; FileReadable:=true;
try try
fs:=TFileStream.Create(UTF8ToSys(AFilename),fmOpenRead); fs := TFileStream.Create(UTF8ToSys(AFilename), fmOpenRead or fmShareDenyNone);
try try
// read the first 1024 bytes // read the first 1024 bytes
Len:=1024; Len:=1024;