X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fhelper-api.c;h=54093e409204de6d3c082d335b67ee86c7d4aff3;hb=c1dda27fbbbbbf14aabe5bc8b4cb2a70abfd09f0;hp=ad0daf6908e64019ee3ebf6eba19e9456c954c1a;hpb=acd9ae252049d89ca7907995d94b6c6b0b643379;p=src%2Fapp-framework-binder.git diff --git a/src/helper-api.c b/src/helper-api.c index ad0daf69..54093e40 100644 --- a/src/helper-api.c +++ b/src/helper-api.c @@ -126,7 +126,7 @@ PUBLIC json_object* getPostFile (AFB_request *request, AFB_PostItem *item, char* // We have a context but last Xform iteration fail or application set a message if (request->jresp != NULL) { jresp = request->jresp; // retrieve previous error from postCtx - } else jresp = jsonNewMessage(AFB_FAIL,"getPostFile Post Request done"); + } else jresp = jsonNewMessage(AFB_SUCCESS,"getPostFile Post Request done"); // Error or not let's free all resources close(postFileCtx->fd); @@ -177,7 +177,7 @@ PUBLIC json_object* getPostFile (AFB_request *request, AFB_PostItem *item, char* // make sure destination directory exist destDir = opendir (filepath); if (destDir == NULL) { - if ( 0 <= mkdir(filepath,O_RDWR | S_IRWXU | S_IRGRP)) { + if (mkdir(filepath,O_RDWR | S_IRWXU | S_IRGRP) < 0) { postFileCtx->jresp= jsonNewMessage(AFB_FAIL,"Fail to Create destination directory=[%s] error=%s\n", filepath, strerror(errno)); goto ExitOnError; } @@ -188,7 +188,7 @@ PUBLIC json_object* getPostFile (AFB_request *request, AFB_PostItem *item, char* postFileCtx->path = strdup (filepath); if (verbose) fprintf(stderr, "getPostFile path=%s\n", filepath); - + if((postFileCtx->fd = open(filepath, O_RDWR |O_CREAT, S_IRWXU|S_IRGRP)) <= 0) { postFileCtx->jresp= jsonNewMessage(AFB_FAIL,"Fail to Create destination File=[%s] error=%s\n", filepath, strerror(errno)); goto ExitOnError;