commit 6fdaa4e5bbcac37a43715b404ec9c6edb0092111
parent 1518875b5e1dbbcc415735b8f1a5b7691e229523
Author: Dominik Schmidt <das1993@hotmail.com>
Date: Thu, 27 Aug 2015 01:16:53 +0200
load file in *Vec: Rather throw than return non-zero
Diffstat:
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/puzzle.d b/puzzle.d
@@ -129,8 +129,10 @@ struct DVec{
~this(){
puzzle_free_dvec(ctx,&vec);
}
- int load(string f){
- return puzzle_fill_dvec_from_file(ctx, &vec, toStringz(f));
+ void load(string f){
+ if(puzzle_fill_dvec_from_file(ctx, &vec, toStringz(f))!=0){
+ throw new Exception("Couldn't read the file");
+ }
}
void load(void mem[]){
puzzle_fill_dvec_from_mem(ctx, &vec, cast(void*)mem, mem.length);
@@ -162,8 +164,10 @@ struct CVec{
~this(){
puzzle_free_cvec(ctx,&vec);
}
- int load(string f) {
- return puzzle_fill_cvec_from_file(ctx, &vec, toStringz(f));
+ void load(string f){
+ if(puzzle_fill_cvec_from_file(ctx, &vec, toStringz(f))!=0){
+ throw new Exception("Couldn't read the file");
+ }
}
void load(void mem[]){
puzzle_fill_cvec_from_mem(ctx, &vec, cast(void*)mem, mem.length);