Mercurial > hg > orthanc
comparison Core/Images/IImageWriter.cpp @ 2170:baf8dd89b4e0
improved support for sandboxed environments
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 23 Nov 2016 11:45:02 +0100 |
parents | fd5875662670 |
children | a3a65de1840f |
comparison
equal
deleted
inserted
replaced
2169:d15de5685ad8 | 2170:baf8dd89b4e0 |
---|---|
30 **/ | 30 **/ |
31 | 31 |
32 | 32 |
33 #include "IImageWriter.h" | 33 #include "IImageWriter.h" |
34 | 34 |
35 #include "../OrthancException.h" | |
36 | |
37 #if !defined(ORTHANC_SANDBOXED) | |
38 # error The macro ORTHANC_SANDBOXED must be defined | |
39 #endif | |
40 | |
41 #if ORTHANC_SANDBOXED == 0 | 35 #if ORTHANC_SANDBOXED == 0 |
42 # include "../SystemToolbox.h" | 36 # include "../SystemToolbox.h" |
43 #endif | 37 #endif |
44 | 38 |
45 namespace Orthanc | 39 namespace Orthanc |
46 { | 40 { |
41 #if ORTHANC_SANDBOXED == 0 | |
47 void IImageWriter::WriteToFileInternal(const std::string& path, | 42 void IImageWriter::WriteToFileInternal(const std::string& path, |
48 unsigned int width, | 43 unsigned int width, |
49 unsigned int height, | 44 unsigned int height, |
50 unsigned int pitch, | 45 unsigned int pitch, |
51 PixelFormat format, | 46 PixelFormat format, |
52 const void* buffer) | 47 const void* buffer) |
53 { | 48 { |
54 #if ORTHANC_SANDBOXED == 0 | |
55 std::string compressed; | 49 std::string compressed; |
56 WriteToMemoryInternal(compressed, width, height, pitch, format, buffer); | 50 WriteToMemoryInternal(compressed, width, height, pitch, format, buffer); |
57 SystemToolbox::WriteFile(compressed, path); | 51 SystemToolbox::WriteFile(compressed, path); |
58 #else | 52 } |
59 throw OrthancException(ErrorCode_CannotWriteFile); // Unavailable in sandboxed environments | |
60 #endif | 53 #endif |
61 } | |
62 } | 54 } |