Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions library/fsl/fsl_fpc.pas
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ TSemaphore = class (TEventObject)
function DeleteDirectory(const DirectoryName: string; OnlyChildren: boolean): boolean;
procedure FileSetReadOnly(const FileName : String; readOnly : boolean);
procedure FileSetModified(const FileName : String; dateTime : TDateTime);
function FileCanBeReadOnly : boolean;

//function ColorToString(Color: TColor): AnsiString;

Expand Down Expand Up @@ -461,9 +462,7 @@ procedure FileSetReadOnly(const FileName : String; readOnly : boolean);
raise EFslException.Create('chmod failed');
{$ENDIF}
{$IFDEF OSX}
begin
raise EFslException.Create('Not supported');
end;
// nothing
{$ENDIF}
end;

Expand All @@ -472,6 +471,16 @@ procedure FileSetModified(const FileName : String; dateTime : TDateTime);
FileSetDate(filename, DateTimeToFileDate(dateTIme));
end;

function FileCanBeReadOnly : boolean;
begin
{$IFDEF OSX}
result := false;
{$ELSE}
result := true;
{$ENDIF}

end;

{ TShortStringHelper }

function TShortStringHelper.substring(start, stop : integer) : String;
Expand Down Expand Up @@ -694,7 +703,7 @@ function TZDecompressionStream.Read(var buffer; count: Longint): Longint;
begin
if FZStream.avail_in = 0 then
begin
FZStream.avail_in := FStream.Read(FBuffer, Length(FBuffer));
FZStream.avail_in := FStream.Read(FBuffer[0], Length(FBuffer));

if FZStream.avail_in = 0 then
begin
Expand Down Expand Up @@ -757,14 +766,14 @@ function TZDecompressionStream.Seek(const Offset: Int64; Origin: TSeekOrigin): I
if localOffset > 0 then
begin
SetLength(buf, BufSize);
for i := 1 to localOffset div BufSize do ReadBuffer(buf, BufSize);
ReadBuffer(buf, localOffset mod BufSize);
for i := 1 to localOffset div BufSize do ReadBuffer(buf[0], BufSize);
ReadBuffer(buf[0], localOffset mod BufSize);
end;
end
else if (Offset = 0) and (Origin = soEnd) then
begin
SetLength(buf, BufSize);
while Read(buf, BufSize) > 0 do ;
while Read(buf[0], BufSize) > 0 do ;
end
else
raise EIOException.Create('Invalid Operation');
Expand Down Expand Up @@ -829,6 +838,7 @@ class function TDirectory.GetFiles(const Path: string): TStringDynArray;
ts.add(fsl_utilities.FilePath([Path, SearchRec.Name]));
until FindNext(SearchRec) <> 0;
end;
FindClose(SearchRec);

result := ts.ToStringArray;
finally
Expand All @@ -850,6 +860,7 @@ class function TDirectory.GetFiles(const Path, Mask: string): TStringDynArray;
ts.add(fsl_utilities.FilePath([Path, SearchRec.Name]));
until FindNext(SearchRec) <> 0;
end;
FindClose(SearchRec);

result := ts.ToStringArray;
finally
Expand All @@ -871,6 +882,7 @@ class function TDirectory.getDirectories(const Path: string): TStringDynArray;
ts.add(fsl_utilities.FilePath([Path, SearchRec.Name]));
until FindNext(SearchRec) <> 0;
end;
FindClose(SearchRec);

result := ts.ToStringArray;
finally
Expand Down
6 changes: 3 additions & 3 deletions library/fsl/fsl_stream.pas
Original file line number Diff line number Diff line change
Expand Up @@ -6030,8 +6030,8 @@ function TTarArchive.FindNext (var DirRec : TTarDirRec) : boolean;

// --- EOF reached?
Result := FALSE;
FStream.ReadBuffer (Rec, RECORDSIZE);
if Rec [0] = #0 then EXIT; // EOF reached
FStream.ReadBuffer(Rec[0], RECORDSIZE);
if Rec [0] = #0 then EXIT; // EOF reached
Result := TRUE;

ClearDirRec (DirRec);
Expand Down Expand Up @@ -6140,7 +6140,7 @@ function TTarArchive.ReadFile : TBytes;
if FBytesToGo = 0 then EXIT;
RestBytes := Records (FBytesToGo) * RECORDSIZE - FBytesToGo;
SetLength (Result, FBytesToGo);
FStream.ReadBuffer(Result, {$IFNDEF FPC}0, {$ENDIF}FBytesToGo);
FStream.ReadBuffer(Result[0], {$IFNDEF FPC}0, {$ENDIF}FBytesToGo);
FStream.Seek (RestBytes, soFromCurrent);
FBytesToGo := 0;
end;
Expand Down
2 changes: 1 addition & 1 deletion library/fsl/fsl_threads.pas
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ procedure TFslExternalProcessThread.execute;
FProcess.Execute;
repeat
SetLength(Buffer, BUF_SIZE);
BytesRead := FProcess.Output.Read(Buffer, BUF_SIZE);
BytesRead := FProcess.Output.Read(Buffer[0], BUF_SIZE);
processOutput(TEncoding.UTF8.GetString(Buffer, 0, BytesRead));
until BytesRead = 0;
FExitCode := FProcess.ExitCode;
Expand Down