-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix FPC compatibility #74
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -263,7 +263,9 @@ TDirItem = record | |
function FindDelimiter(const Delimiters, S: string; StartIdx: Integer = 1): Integer; | ||
{$ENDIF} | ||
function ConvertDateTimeToFileTime(const DateTime: TDateTime; const UseLocalTimeZone: Boolean): TFileTime; | ||
{$ifdef mswindows} | ||
function ConvertFileTimeToDateTime(const FileTime : TFileTime; const UseLocalTimeZone : Boolean) : TDateTime; | ||
{$endif mswindows} | ||
procedure SetDateTimeInfo(const Path: string; const CreationTime, LastAccessTime, LastWriteTime: PDateTime; const UseLocalTimeZone: Boolean); | ||
function GetFiles(const Path : string; Recursive : Boolean) : TArray<TDirItem>; overload; | ||
procedure GetFiles(const Path : string; aAddToList : TDirItemAddProc; Recursive : Boolean); overload; | ||
|
@@ -1309,8 +1311,10 @@ function GetFiles(const Path : string; Recursive : Boolean) : TArray<TDirItem>; | |
diritem.Name := rec.Name; | ||
diritem.IsDirectory := False; | ||
diritem.Size := rec.Size; | ||
{$ifdef SEARCHREC_USEFINDDATA} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add FPC to conditional because this is a FPC only conditional |
||
diritem.CreationDate := ConvertFileTimeToDateTime(rec.FindData.ftCreationTime,True); | ||
diritem.LastModified := ConvertFileTimeToDateTime(rec.FindData.ftLastWriteTime,True); | ||
{$endif SEARCHREC_USEFINDDATA} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add FPC to conditional because this is a FPC only conditional |
||
Result := Result + [diritem]; | ||
end | ||
else | ||
|
@@ -1336,8 +1340,10 @@ procedure GetFiles(const Path : string; aAddToList : TDirItemAddProc; Recursive | |
diritem.Name := rec.Name; | ||
diritem.IsDirectory := False; | ||
diritem.Size := rec.Size; | ||
{$ifdef SEARCHREC_USEFINDDATA} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add FPC to conditional because this is a FPC only conditional |
||
diritem.CreationDate := ConvertFileTimeToDateTime(rec.FindData.ftCreationTime,True); | ||
diritem.LastModified := ConvertFileTimeToDateTime(rec.FindData.ftLastWriteTime,True); | ||
{$endif SEARCHREC_USEFINDDATA} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add FPC to conditional because this is a FPC only conditional |
||
aAddToList(diritem); | ||
end | ||
else | ||
|
@@ -1363,8 +1369,10 @@ function GetDirectories(const Path : string; Recursive : Boolean) : TArray<TDirI | |
diritem.Name := rec.Name; | ||
diritem.IsDirectory := True; | ||
diritem.Size := rec.Size; | ||
{$ifdef SEARCHREC_USEFINDDATA} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add FPC to conditional because this is a FPC only conditional |
||
diritem.CreationDate := ConvertFileTimeToDateTime(rec.FindData.ftCreationTime,True); | ||
diritem.LastModified := ConvertFileTimeToDateTime(rec.FindData.ftLastWriteTime,True); | ||
{$endif SEARCHREC_USEFINDDATA} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add FPC to conditional because this is a FPC only conditional |
||
Result := Result + [diritem]; | ||
if Recursive then Result := Result + GetFiles(IncludeTrailingPathDelimiter(Path) + diritem.Name,Recursive); | ||
end; | ||
|
@@ -1402,17 +1410,23 @@ function GetFilesAndDirectories(const Path : string; Recursive : Boolean) : TArr | |
diritem.Name := rec.Name; | ||
diritem.IsDirectory := False; | ||
diritem.Size := rec.Size; | ||
{$ifdef SEARCHREC_USEFINDDATA} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add FPC to conditional because this is a FPC only conditional |
||
diritem.CreationDate := ConvertFileTimeToDateTime(rec.FindData.ftCreationTime,True); | ||
diritem.LastModified := ConvertFileTimeToDateTime(rec.FindData.ftLastWriteTime,True); | ||
{$endif SEARCHREC_USEFINDDATA} | ||
|
||
Result := Result + [diritem]; | ||
end | ||
else if (rec.Name <> '.') and (rec.Name <> '..') then | ||
begin | ||
diritem.Name := rec.Name; | ||
diritem.IsDirectory := True; | ||
diritem.Size := rec.Size; | ||
{$ifdef SEARCHREC_USEFINDDATA} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add FPC to conditional because this is a FPC only conditional |
||
diritem.CreationDate := ConvertFileTimeToDateTime(rec.FindData.ftCreationTime,True); | ||
diritem.LastModified := ConvertFileTimeToDateTime(rec.FindData.ftLastWriteTime,True); | ||
{$endif SEARCHREC_USEFINDDATA} | ||
|
||
Result := Result + [diritem]; | ||
if Recursive then Result := Result + GetFilesAndDirectories(dirpath + diritem.Name,Recursive); | ||
end; | ||
|
@@ -1452,17 +1466,23 @@ procedure GetFilesAndDirectories(const Path : string; aAddToList : TDirItemAddPr | |
diritem.Name := rec.Name; | ||
diritem.IsDirectory := False; | ||
diritem.Size := rec.Size; | ||
{$ifdef SEARCHREC_USEFINDDATA} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add FPC to conditional because this is a FPC only conditional |
||
diritem.CreationDate := ConvertFileTimeToDateTime(rec.FindData.ftCreationTime,True); | ||
diritem.LastModified := ConvertFileTimeToDateTime(rec.FindData.ftLastWriteTime,True); | ||
{$endif SEARCHREC_USEFINDDATA} | ||
|
||
aAddToList(diritem); | ||
end | ||
else if (rec.Name <> '.') and (rec.Name <> '..') then | ||
begin | ||
diritem.Name := rec.Name; | ||
diritem.IsDirectory := True; | ||
diritem.Size := rec.Size; | ||
{$ifdef SEARCHREC_USEFINDDATA} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add FPC to conditional because this is a FPC only conditional |
||
diritem.CreationDate := ConvertFileTimeToDateTime(rec.FindData.ftCreationTime,True); | ||
diritem.LastModified := ConvertFileTimeToDateTime(rec.FindData.ftLastWriteTime,True); | ||
{$endif SEARCHREC_USEFINDDATA} | ||
|
||
aAddToList(diritem); | ||
if Recursive then GetFilesAndDirectories(dirpath + diritem.Name,aAddToList,Recursive); | ||
end; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,8 +164,8 @@ TRTTIJson = class | |
//serialize methods | ||
function SerializeValue(const aValue : TValue) : TJSONValue; | ||
function SerializeObject(aObject : TObject) : TJSONObject; overload; | ||
function SerializeStream(aObject : TObject) : TJSONValue; | ||
{$IFNDEF FPC} | ||
function SerializeStream(aObject : TObject) : TJSONValue; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i've moved outside conditional because is fpc compatible |
||
function SerializeDynArray(const aValue: TValue; aMaxElements : Integer = -1) : TJsonArray; | ||
function SerializeRecord(const aValue : TValue) : TJSONValue; | ||
{$ELSE} | ||
|
@@ -213,7 +213,9 @@ TJsonSerializer = class(TInterfacedObject,IJsonSerializer) | |
property UseNullStringsAsEmpty : Boolean read fUseNullStringsAsEmpty write fUseNullStringsAsEmpty; | ||
function JsonToObject(aType : TClass; const aJson: string) : TObject; overload; | ||
function JsonToObject(aObject : TObject; const aJson: string) : TObject; overload; | ||
{$IFNDEF FPC} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i've moved outside conditional because is fpc compatible |
||
function JsonStreamToObject(aObject : TObject; aJsonStream : TStream) : TObject; | ||
{$ENDIF} | ||
function ObjectToJson(aObject : TObject; aIndent : Boolean = False): string; | ||
function ObjectToJsonString(aObject : TObject; aIndent : Boolean = False): string; | ||
procedure ObjectToJsonStream(aObject : TObject; aStream : TStream); | ||
|
@@ -450,21 +452,21 @@ function TRTTIJson.DeserializeRecord(const aRecord : TValue; aObject : TObject; | |
end; | ||
Result := aRecord; | ||
end; | ||
{$ENDIF} | ||
|
||
function TRTTIJson.DeserializeStream(aObject: TObject; const aJson: TJSONValue): TObject; | ||
var | ||
stream : TStringStream; | ||
begin | ||
if fUseBase64Stream then stream := TStringStream.Create(Base64Decode(aJson.Value),TEncoding.Ansi) | ||
else stream := TStringStream.Create(aJson.Value,TEncoding.Ansi); | ||
else stream := TStringStream.Create(String(aJson.Value),TEncoding.Ansi); | ||
try | ||
TStream(aObject).CopyFrom(stream,stream.Size); | ||
finally | ||
stream.Free; | ||
end; | ||
end; | ||
|
||
{$ENDIF} | ||
|
||
constructor TRTTIJson.Create(aSerializeLevel : TSerializeLevel; aUseEnumNames : Boolean = True); | ||
begin | ||
fSerializeLevel := aSerializeLevel; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change it to {IF DEFINED(DELPHIXE_UP) OR (DEFINED(FPC) AND DEFINED(MSWINDOWS))} because it's delphi crossplatform compatible