added function to test a dub project validity

valid for Coedit = only JSON
This commit is contained in:
Basile Burg 2015-09-09 13:52:20 +02:00
parent ce2d63713d
commit 63dedff146
1 changed files with 29 additions and 1 deletions

View File

@ -56,9 +56,12 @@ type
property json: TJSONObject read fJson; property json: TJSONObject read fJson;
end; end;
// these 9 built types alway exist // these 9 built types always exist
TDubBuildType = (plain, debug, release, unittest, docs, ddox, profile, cov, unittestcov); TDubBuildType = (plain, debug, release, unittest, docs, ddox, profile, cov, unittestcov);
// returns true iffilename is a valid dub project. Only json format is supported.
function isValidDubProject(const filename: string): boolean;
const const
DubBuiltTypeName: array[TDubBuildType] of string = ('plain', 'debug', 'release', DubBuiltTypeName: array[TDubBuildType] of string = ('plain', 'debug', 'release',
@ -320,5 +323,30 @@ begin
result := false; result := false;
end; end;
function isValidDubProject(const filename: string): boolean;
var
maybe: TCEDubProject;
begin
result := true;
// avoid the project to notify the observers, current project is not replaced
EntitiesConnector.beginUpdate;
maybe := TCEDubProject.create(nil);
EntitiesConnector.removeSubject(maybe);
try
try
maybe.loadFromFile(filename);
if maybe.json = nil then
result := false
else if maybe.json.Find('name') = nil then
result := false;
except
result := false;
end;
finally
maybe.Free;
EntitiesConnector.endUpdate;
end;
end;
end. end.