Mercurial > hg > orthanc
diff Plugins/Samples/StorageArea/Plugin.cpp @ 1627:da7854deb662
Plugin callbacks must now return explicit "OrthancPluginErrorCode" instead of integers
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 18 Sep 2015 16:32:29 +0200 |
parents | 97268448bdfc |
children | 87c77b9b3679 |
line wrap: on
line diff
--- a/Plugins/Samples/StorageArea/Plugin.cpp Fri Sep 18 14:28:47 2015 +0200 +++ b/Plugins/Samples/StorageArea/Plugin.cpp Fri Sep 18 16:32:29 2015 +0200 @@ -33,43 +33,43 @@ } -static int32_t StorageCreate(const char* uuid, - const void* content, - int64_t size, - OrthancPluginContentType type) +static OrthancPluginErrorCode StorageCreate(const char* uuid, + const void* content, + int64_t size, + OrthancPluginContentType type) { std::string path = GetPath(uuid); FILE* fp = fopen(path.c_str(), "wb"); if (!fp) { - return -1; + return OrthancPluginErrorCode_Plugin; } bool ok = fwrite(content, size, 1, fp) == 1; fclose(fp); - return ok ? 0 : -1; + return ok ? OrthancPluginErrorCode_Success : OrthancPluginErrorCode_Plugin; } -static int32_t StorageRead(void** content, - int64_t* size, - const char* uuid, - OrthancPluginContentType type) +static OrthancPluginErrorCode StorageRead(void** content, + int64_t* size, + const char* uuid, + OrthancPluginContentType type) { std::string path = GetPath(uuid); FILE* fp = fopen(path.c_str(), "rb"); if (!fp) { - return -1; + return OrthancPluginErrorCode_Plugin; } if (fseek(fp, 0, SEEK_END) < 0) { fclose(fp); - return -1; + return OrthancPluginErrorCode_Plugin; } *size = ftell(fp); @@ -77,7 +77,7 @@ if (fseek(fp, 0, SEEK_SET) < 0) { fclose(fp); - return -1; + return OrthancPluginErrorCode_Plugin; } bool ok = true; @@ -98,15 +98,23 @@ fclose(fp); - return ok ? 0 : -1; + return ok ? OrthancPluginErrorCode_Success : OrthancPluginErrorCode_Plugin; } -static int32_t StorageRemove(const char* uuid, - OrthancPluginContentType type) +static OrthancPluginErrorCode StorageRemove(const char* uuid, + OrthancPluginContentType type) { std::string path = GetPath(uuid); - return remove(path.c_str()); + + if (remove(path.c_str()) == 0) + { + return OrthancPluginErrorCode_Success; + } + else + { + return OrthancPluginErrorCode_Plugin; + } }