setup, still cases resources were copied

This commit is contained in:
Basile Burg 2016-11-21 00:39:34 +01:00
parent 60f428bc3d
commit cbc86793f6
No known key found for this signature in database
GPG Key ID: 1868039F415CB8CF
1 changed files with 11 additions and 8 deletions

View File

@ -26,12 +26,13 @@ enum Kind
struct Resource struct Resource
{ {
@disable this(this);
ImpType data; ImpType data;
immutable string destName; immutable string destName;
immutable Kind kind; immutable Kind kind;
} }
Resource[] ceResources = immutable Resource[] ceResources =
[ [
Resource(cast(ImpType) import("coedit" ~ exeExt), "coedit" ~ exeExt, Kind.exe), Resource(cast(ImpType) import("coedit" ~ exeExt), "coedit" ~ exeExt, Kind.exe),
Resource(cast(ImpType) import("dastworx" ~ exeExt), "dastworx" ~ exeExt, Kind.exe), Resource(cast(ImpType) import("dastworx" ~ exeExt), "dastworx" ~ exeExt, Kind.exe),
@ -40,14 +41,14 @@ Resource[] ceResources =
Resource(cast(ImpType) import("coedit.license.txt"), "coedit.license.txt", Kind.doc) Resource(cast(ImpType) import("coedit.license.txt"), "coedit.license.txt", Kind.doc)
]; ];
Resource[] dcdResources = immutable Resource[] dcdResources =
[ [
Resource(cast(ImpType) import("dcd-server" ~ exeExt), "dcd-server" ~ exeExt, Kind.exe), Resource(cast(ImpType) import("dcd-server" ~ exeExt), "dcd-server" ~ exeExt, Kind.exe),
Resource(cast(ImpType) import("dcd-client" ~ exeExt), "dcd-client" ~ exeExt, Kind.exe), Resource(cast(ImpType) import("dcd-client" ~ exeExt), "dcd-client" ~ exeExt, Kind.exe),
Resource(cast(ImpType) import("dcd.license.txt"), "dcd.license.txt", Kind.doc) Resource(cast(ImpType) import("dcd.license.txt"), "dcd.license.txt", Kind.doc)
]; ];
Resource[] oldResources = immutable Resource[] oldResources =
[ [
Resource(cast(ImpType) [], "cesyms" ~ exeExt, Kind.exe), Resource(cast(ImpType) [], "cesyms" ~ exeExt, Kind.exe),
Resource(cast(ImpType) [], "cetodo" ~ exeExt, Kind.exe), Resource(cast(ImpType) [], "cetodo" ~ exeExt, Kind.exe),
@ -292,7 +293,7 @@ void main(string[] args)
} }
/// Returns the resource target filename, according to its Kind /// Returns the resource target filename, according to its Kind
string targetFilename(Resource resource) string targetFilename(ref ResType resource)
{ {
with(Kind) final switch(resource.kind) with(Kind) final switch(resource.kind)
{ {
@ -303,7 +304,7 @@ string targetFilename(Resource resource)
} }
/// Extracts and writes a resource to a file. /// Extracts and writes a resource to a file.
bool installResource(Resource resource) bool installResource(ref ResType resource)
{ {
const string fname = resource.targetFilename; const string fname = resource.targetFilename;
const string path = fname.dirName; const string path = fname.dirName;
@ -328,11 +329,13 @@ bool installResource(Resource resource)
} }
/// Deletes the file created for a resource /// Deletes the file created for a resource
bool uninstallResource(Resource resource) bool uninstallResource(ref ResType resource)
{ {
const string fname = resource.targetFilename; const string fname = resource.targetFilename;
if (!fname.exists) return true; if (!fname.exists)
else return tryRemove(fname); return true;
else
return tryRemove(fname);
} }
/// returns true if fname is deleted /// returns true if fname is deleted