added function to test if a file is a native project

This commit is contained in:
Basile Burg 2015-08-24 14:47:48 +02:00
parent f9d8bd95b2
commit 104d6bc3b6
1 changed files with 21 additions and 0 deletions

View File

@ -91,6 +91,9 @@ type
property outputFilename: string read fOutputFilename;
end;
// native project have no ext constraint, this function tells if filename is project
function isValidNativeProject(const filename: string): boolean;
implementation
uses
@ -771,6 +774,24 @@ begin
end;
end;
function isValidNativeProject(const filename: string): boolean;
var
maybe: TCENativeProject;
begin
result := false;
// avoid the project to notify the observers, current project is not replaced
EntitiesConnector.beginUpdate;
maybe := TCENativeProject.create(nil);
EntitiesConnector.removeSubject(maybe);
try
maybe.loadFromFile(filename);
result := maybe.hasLoaded;
finally
maybe.Free;
EntitiesConnector.endUpdate;
end;
end;
initialization
RegisterClasses([TCENativeProject]);
end.