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
8 changes: 6 additions & 2 deletions Source/RemObjects.Elements.RTL/Binary.pas
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,12 @@ constructor Binary(Bin: ImmutableBinary);
{$IF COOPER}
result := fData.toByteArray as not nullable;
{$ELSEIF TOFFEE}
result := new Byte[mapped.length];
mapped.getBytes(result) length(mapped.length);
if mapped.length = 0 then
exit []
else begin
result := new Byte[mapped.length];
mapped.getBytes(result) length(mapped.length);
end;
{$ELSEIF ECHOES OR ISLAND}
result := mapped.ToArray as not nullable;
{$ENDIF}
Expand Down
5 changes: 4 additions & 1 deletion Source/RemObjects.Elements.RTL/File.pas
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,10 @@ constructor File(aPath: not nullable String);
class method File.WriteBytes(aFileName: String; Content: array of Byte);
begin
{$IF TOFFEE}
(new Binary(Content) as NSData).writeToURL(NSURL.fileURLWithPath(aFileName)) atomically(true);
if length(Content) > 0 then
(new Binary(Content) as NSData).writeToURL(NSURL.fileURLWithPath(aFileName)) atomically(true)
else
NSData.data.writeToURL(NSURL.fileURLWithPath(aFileName)) atomically(true);
{$ELSE}
var Handle := new FileHandle(aFileName, FileOpenMode.Create);
try
Expand Down