Mercurial > hg > orthanc
changeset 2142:5a8840920121
reorganization
line wrap: on
line diff
--- a/CMakeLists.txt Wed Nov 09 16:16:26 2016 +0100 +++ b/CMakeLists.txt Wed Nov 09 16:26:40 2016 +0100 @@ -146,8 +146,8 @@ Core/SQLite/StatementId.cpp Core/SQLite/StatementReference.cpp Core/SQLite/Transaction.cpp + Core/TemporaryFile.cpp Core/Toolbox.cpp - Core/Uuid.cpp Core/WebServiceParameters.cpp Core/Lua/LuaContext.cpp Core/Lua/LuaFunctionCall.cpp
--- a/Core/Cache/SharedArchive.cpp Wed Nov 09 16:16:26 2016 +0100 +++ b/Core/Cache/SharedArchive.cpp Wed Nov 09 16:26:40 2016 +0100 @@ -34,9 +34,6 @@ #include "SharedArchive.h" -#include "../Uuid.h" - - namespace Orthanc { void SharedArchive::RemoveInternal(const std::string& id)
--- a/Core/FileStorage/FilesystemStorage.cpp Wed Nov 09 16:16:26 2016 +0100 +++ b/Core/FileStorage/FilesystemStorage.cpp Wed Nov 09 16:26:40 2016 +0100 @@ -39,7 +39,6 @@ #include "../Logging.h" #include "../OrthancException.h" #include "../Toolbox.h" -#include "../Uuid.h" #include <boost/filesystem/fstream.hpp>
--- a/Core/FileStorage/StorageAccessor.cpp Wed Nov 09 16:16:26 2016 +0100 +++ b/Core/FileStorage/StorageAccessor.cpp Wed Nov 09 16:26:40 2016 +0100 @@ -36,6 +36,7 @@ #include "../Compression/ZlibCompressor.h" #include "../OrthancException.h" #include "../HttpServer/HttpStreamTranscoder.h" +#include "../Toolbox.h" namespace Orthanc {
--- a/Core/HttpServer/HttpOutput.h Wed Nov 09 16:16:26 2016 +0100 +++ b/Core/HttpServer/HttpOutput.h Wed Nov 09 16:26:40 2016 +0100 @@ -32,13 +32,14 @@ #pragma once +#include "../Enumerations.h" +#include "IHttpOutputStream.h" +#include "IHttpStreamAnswer.h" + #include <list> #include <string> #include <stdint.h> -#include "../Enumerations.h" -#include "IHttpOutputStream.h" -#include "IHttpStreamAnswer.h" -#include "../Uuid.h" +#include <map> namespace Orthanc {
--- a/Core/HttpServer/IHttpHandler.h Wed Nov 09 16:16:26 2016 +0100 +++ b/Core/HttpServer/IHttpHandler.h Wed Nov 09 16:26:40 2016 +0100 @@ -32,7 +32,7 @@ #pragma once -#include "../Enumerations.h" +#include "../Toolbox.h" #include "HttpOutput.h" #include <map>
--- a/Core/RestApi/RestApiOutput.cpp Wed Nov 09 16:16:26 2016 +0100 +++ b/Core/RestApi/RestApiOutput.cpp Wed Nov 09 16:26:40 2016 +0100 @@ -35,6 +35,7 @@ #include "../Logging.h" #include "../OrthancException.h" +#include "../Toolbox.h" #include <boost/lexical_cast.hpp>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Core/TemporaryFile.cpp Wed Nov 09 16:26:40 2016 +0100 @@ -0,0 +1,79 @@ +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics + * Department, University Hospital of Liege, Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * In addition, as a special exception, the copyright holders of this + * program give permission to link the code of its release with the + * OpenSSL project's "OpenSSL" library (or with modified versions of it + * that use the same license as the "OpenSSL" library), and distribute + * the linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If you + * modify file(s) with this exception, you may extend this exception to + * your version of the file(s), but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source files + * in the program, then also delete it here. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + **/ + + +#include "PrecompiledHeaders.h" +#include "TemporaryFile.h" + +#include <boost/filesystem.hpp> + +namespace Orthanc +{ + static std::string CreateTemporaryPath(const char* extension) + { +#if BOOST_HAS_FILESYSTEM_V3 == 1 + boost::filesystem::path tmpDir = boost::filesystem::temp_directory_path(); +#elif defined(__linux__) + boost::filesystem::path tmpDir("/tmp"); +#else +#error Support your platform here +#endif + + // We use UUID to create unique path to temporary files + std::string filename = "Orthanc-" + Orthanc::Toolbox::GenerateUuid(); + + if (extension != NULL) + { + filename.append(extension); + } + + tmpDir /= filename; + return tmpDir.string(); + } + + + TemporaryFile::TemporaryFile() : + path_(CreateTemporaryPath(NULL)) + { + } + + + TemporaryFile::TemporaryFile(const char* extension) : + path_(CreateTemporaryPath(extension)) + { + } + + + TemporaryFile::~TemporaryFile() + { + boost::filesystem::remove(path_); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Core/TemporaryFile.h Wed Nov 09 16:26:40 2016 +0100 @@ -0,0 +1,76 @@ +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics + * Department, University Hospital of Liege, Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * In addition, as a special exception, the copyright holders of this + * program give permission to link the code of its release with the + * OpenSSL project's "OpenSSL" library (or with modified versions of it + * that use the same license as the "OpenSSL" library), and distribute + * the linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If you + * modify file(s) with this exception, you may extend this exception to + * your version of the file(s), but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source files + * in the program, then also delete it here. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + **/ + + +#pragma once + +#include <string> + +#if !defined(ORTHANC_SANDBOXED) +# define ORTHANC_SANDBOXED 0 +#endif + +#if ORTHANC_SANDBOXED == 1 +# error The class TemporaryFile cannot be used in sandboxed environments +#endif + +#include "Toolbox.h" + +namespace Orthanc +{ + class TemporaryFile + { + private: + std::string path_; + + public: + TemporaryFile(); + + TemporaryFile(const char* extension); + + ~TemporaryFile(); + + const std::string& GetPath() const + { + return path_; + } + + void Write(const std::string& content) + { + SystemToolbox::WriteFile(content, path_); + } + + void Read(std::string& content) const + { + SystemToolbox::ReadFile(content, path_); + } + }; +}
--- a/Core/Uuid.cpp Wed Nov 09 16:16:26 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -/** - * Orthanc - A Lightweight, RESTful DICOM Store - * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics - * Department, University Hospital of Liege, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * In addition, as a special exception, the copyright holders of this - * program give permission to link the code of its release with the - * OpenSSL project's "OpenSSL" library (or with modified versions of it - * that use the same license as the "OpenSSL" library), and distribute - * the linked executables. You must obey the GNU General Public License - * in all respects for all of the code used other than "OpenSSL". If you - * modify file(s) with this exception, you may extend this exception to - * your version of the file(s), but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. If you delete this exception statement from all source files - * in the program, then also delete it here. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - **/ - - -#include "PrecompiledHeaders.h" -#include "Uuid.h" - -#include <boost/filesystem.hpp> - -namespace Orthanc -{ - static std::string CreateTemporaryPath(const char* extension) - { -#if BOOST_HAS_FILESYSTEM_V3 == 1 - boost::filesystem::path tmpDir = boost::filesystem::temp_directory_path(); -#elif defined(__linux__) - boost::filesystem::path tmpDir("/tmp"); -#else -#error Support your platform here -#endif - - // We use UUID to create unique path to temporary files - std::string filename = "Orthanc-" + Orthanc::Toolbox::GenerateUuid(); - - if (extension != NULL) - { - filename.append(extension); - } - - tmpDir /= filename; - return tmpDir.string(); - } - - -#if ORTHANC_SANDBOXED == 0 - TemporaryFile::TemporaryFile() : - path_(CreateTemporaryPath(NULL)) - { - } - - - TemporaryFile::TemporaryFile(const char* extension) : - path_(CreateTemporaryPath(extension)) - { - } - - - TemporaryFile::~TemporaryFile() - { - boost::filesystem::remove(path_); - } -#endif -}
--- a/Core/Uuid.h Wed Nov 09 16:16:26 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -/** - * Orthanc - A Lightweight, RESTful DICOM Store - * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics - * Department, University Hospital of Liege, Belgium - * - * This program is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * In addition, as a special exception, the copyright holders of this - * program give permission to link the code of its release with the - * OpenSSL project's "OpenSSL" library (or with modified versions of it - * that use the same license as the "OpenSSL" library), and distribute - * the linked executables. You must obey the GNU General Public License - * in all respects for all of the code used other than "OpenSSL". If you - * modify file(s) with this exception, you may extend this exception to - * your version of the file(s), but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. If you delete this exception statement from all source files - * in the program, then also delete it here. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - **/ - - -#pragma once - -#include <string> - -#if !defined(ORTHANC_SANDBOXED) -# define ORTHANC_SANDBOXED 0 -#endif - -#include "Toolbox.h" - -namespace Orthanc -{ -#if ORTHANC_SANDBOXED == 0 - class TemporaryFile - { - private: - std::string path_; - - public: - TemporaryFile(); - - TemporaryFile(const char* extension); - - ~TemporaryFile(); - - const std::string& GetPath() const - { - return path_; - } - - void Write(const std::string& content) - { - SystemToolbox::WriteFile(content, path_); - } - - void Read(std::string& content) const - { - SystemToolbox::ReadFile(content, path_); - } - }; -#endif -}
--- a/OrthancServer/DatabaseWrapper.cpp Wed Nov 09 16:16:26 2016 +0100 +++ b/OrthancServer/DatabaseWrapper.cpp Wed Nov 09 16:26:40 2016 +0100 @@ -35,7 +35,6 @@ #include "../Core/DicomFormat/DicomArray.h" #include "../Core/Logging.h" -#include "../Core/Uuid.h" #include "EmbeddedResources.h" #include "ServerToolbox.h"
--- a/OrthancServer/DicomDirWriter.cpp Wed Nov 09 16:16:26 2016 +0100 +++ b/OrthancServer/DicomDirWriter.cpp Wed Nov 09 16:26:40 2016 +0100 @@ -105,7 +105,7 @@ #include "../Core/Logging.h" #include "../Core/OrthancException.h" -#include "../Core/Uuid.h" +#include "../Core/TemporaryFile.h" #include <dcmtk/dcmdata/dcdicdir.h> #include <dcmtk/dcmdata/dcmetinf.h>
--- a/OrthancServer/DicomProtocol/DicomServer.cpp Wed Nov 09 16:16:26 2016 +0100 +++ b/OrthancServer/DicomProtocol/DicomServer.cpp Wed Nov 09 16:26:40 2016 +0100 @@ -36,7 +36,6 @@ #include "../../Core/Logging.h" #include "../../Core/OrthancException.h" #include "../../Core/Toolbox.h" -#include "../../Core/Uuid.h" #include "../Internals/CommandDispatcher.h" #include "../OrthancInitialization.h" #include "EmbeddedResources.h"
--- a/OrthancServer/FromDcmtkBridge.cpp Wed Nov 09 16:16:26 2016 +0100 +++ b/OrthancServer/FromDcmtkBridge.cpp Wed Nov 09 16:26:40 2016 +0100 @@ -40,7 +40,7 @@ #include "ToDcmtkBridge.h" #include "../Core/Logging.h" #include "../Core/Toolbox.h" -#include "../Core/Uuid.h" +#include "../Core/TemporaryFile.h" #include "../Core/OrthancException.h" #include <list>
--- a/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp Wed Nov 09 16:16:26 2016 +0100 +++ b/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp Wed Nov 09 16:26:40 2016 +0100 @@ -34,7 +34,6 @@ #include "OrthancRestApi.h" #include "../../Core/Logging.h" -#include "../../Core/Uuid.h" #include "../FromDcmtkBridge.h" #include "../ServerContext.h" #include "../OrthancInitialization.h"
--- a/OrthancServer/OrthancRestApi/OrthancRestArchive.cpp Wed Nov 09 16:16:26 2016 +0100 +++ b/OrthancServer/OrthancRestApi/OrthancRestArchive.cpp Wed Nov 09 16:26:40 2016 +0100 @@ -38,7 +38,7 @@ #include "../../Core/Compression/HierarchicalZipWriter.h" #include "../../Core/HttpServer/FilesystemHttpSender.h" #include "../../Core/Logging.h" -#include "../../Core/Uuid.h" +#include "../../Core/TemporaryFile.h" #include "../ServerContext.h" #include <stdio.h>
--- a/OrthancServer/ParsedDicomFile.cpp Wed Nov 09 16:16:26 2016 +0100 +++ b/OrthancServer/ParsedDicomFile.cpp Wed Nov 09 16:26:40 2016 +0100 @@ -90,7 +90,6 @@ #include "../Core/Logging.h" #include "../Core/OrthancException.h" #include "../Core/Toolbox.h" -#include "../Core/Uuid.h" #include <list> #include <limits>
--- a/OrthancServer/ParsedDicomFile.h Wed Nov 09 16:16:26 2016 +0100 +++ b/OrthancServer/ParsedDicomFile.h Wed Nov 09 16:26:40 2016 +0100 @@ -36,6 +36,7 @@ #include "../Core/Images/ImageAccessor.h" #include "../Core/IDynamicObject.h" #include "../Core/RestApi/RestApiOutput.h" +#include "../Core/Toolbox.h" #include "ServerEnumerations.h" class DcmDataset;
--- a/OrthancServer/Scheduler/CallSystemCommand.cpp Wed Nov 09 16:16:26 2016 +0100 +++ b/OrthancServer/Scheduler/CallSystemCommand.cpp Wed Nov 09 16:26:40 2016 +0100 @@ -35,7 +35,7 @@ #include "../../Core/Logging.h" #include "../../Core/Toolbox.h" -#include "../../Core/Uuid.h" +#include "../../Core/TemporaryFile.h" namespace Orthanc {
--- a/OrthancServer/Scheduler/ServerJob.cpp Wed Nov 09 16:16:26 2016 +0100 +++ b/OrthancServer/Scheduler/ServerJob.cpp Wed Nov 09 16:26:40 2016 +0100 @@ -35,7 +35,6 @@ #include "../../Core/OrthancException.h" #include "../../Core/Toolbox.h" -#include "../../Core/Uuid.h" namespace Orthanc {
--- a/OrthancServer/ServerIndex.cpp Wed Nov 09 16:16:26 2016 +0100 +++ b/OrthancServer/ServerIndex.cpp Wed Nov 09 16:26:40 2016 +0100 @@ -43,7 +43,6 @@ #include "ServerToolbox.h" #include "../Core/Toolbox.h" #include "../Core/Logging.h" -#include "../Core/Uuid.h" #include "../Core/DicomFormat/DicomArray.h" #include "FromDcmtkBridge.h"
--- a/OrthancServer/main.cpp Wed Nov 09 16:16:26 2016 +0100 +++ b/OrthancServer/main.cpp Wed Nov 09 16:26:40 2016 +0100 @@ -36,7 +36,6 @@ #include <boost/algorithm/string/predicate.hpp> #include "../Core/Logging.h" -#include "../Core/Uuid.h" #include "../Core/HttpServer/EmbeddedResourceHttpHandler.h" #include "../Core/HttpServer/FilesystemHttpHandler.h" #include "../Core/Lua/LuaFunctionCall.h"
--- a/UnitTestsSources/DicomMapTests.cpp Wed Nov 09 16:16:26 2016 +0100 +++ b/UnitTestsSources/DicomMapTests.cpp Wed Nov 09 16:26:40 2016 +0100 @@ -33,7 +33,6 @@ #include "PrecompiledHeadersUnitTests.h" #include "gtest/gtest.h" -#include "../Core/Uuid.h" #include "../Core/OrthancException.h" #include "../Core/DicomFormat/DicomMap.h" #include "../OrthancServer/FromDcmtkBridge.h"
--- a/UnitTestsSources/FileStorageTests.cpp Wed Nov 09 16:16:26 2016 +0100 +++ b/UnitTestsSources/FileStorageTests.cpp Wed Nov 09 16:26:40 2016 +0100 @@ -42,7 +42,6 @@ #include "../Core/Logging.h" #include "../Core/OrthancException.h" #include "../Core/Toolbox.h" -#include "../Core/Uuid.h" #include "../OrthancServer/ServerIndex.h" using namespace Orthanc;
--- a/UnitTestsSources/FromDcmtkTests.cpp Wed Nov 09 16:16:26 2016 +0100 +++ b/UnitTestsSources/FromDcmtkTests.cpp Wed Nov 09 16:26:40 2016 +0100 @@ -44,7 +44,6 @@ #include "../Core/Images/PngWriter.h" #include "../Core/Images/Image.h" #include "../Core/Images/ImageProcessing.h" -#include "../Core/Uuid.h" #include "../Core/Endianness.h" #include "../Resources/EncodingTests.h" #include "../OrthancServer/DicomProtocol/DicomFindAnswers.h"
--- a/UnitTestsSources/ImageTests.cpp Wed Nov 09 16:16:26 2016 +0100 +++ b/UnitTestsSources/ImageTests.cpp Wed Nov 09 16:26:40 2016 +0100 @@ -41,7 +41,7 @@ #include "../Core/Images/PngReader.h" #include "../Core/Images/PngWriter.h" #include "../Core/Toolbox.h" -#include "../Core/Uuid.h" +#include "../Core/TemporaryFile.h" #include "../OrthancServer/OrthancInitialization.h" #include <stdint.h>
--- a/UnitTestsSources/RestApiTests.cpp Wed Nov 09 16:16:26 2016 +0100 +++ b/UnitTestsSources/RestApiTests.cpp Wed Nov 09 16:26:40 2016 +0100 @@ -41,7 +41,6 @@ #include "../Core/HttpClient.h" #include "../Core/Logging.h" #include "../Core/RestApi/RestApi.h" -#include "../Core/Uuid.h" #include "../Core/OrthancException.h" #include "../Core/Compression/ZlibCompressor.h" #include "../Core/RestApi/RestApiHierarchy.h"
--- a/UnitTestsSources/ServerIndexTests.cpp Wed Nov 09 16:16:26 2016 +0100 +++ b/UnitTestsSources/ServerIndexTests.cpp Wed Nov 09 16:26:40 2016 +0100 @@ -35,7 +35,6 @@ #include "../Core/FileStorage/FilesystemStorage.h" #include "../Core/Logging.h" -#include "../Core/Uuid.h" #include "../OrthancServer/DatabaseWrapper.h" #include "../OrthancServer/ServerContext.h" #include "../OrthancServer/ServerIndex.h"
--- a/UnitTestsSources/StreamTests.cpp Wed Nov 09 16:16:26 2016 +0100 +++ b/UnitTestsSources/StreamTests.cpp Wed Nov 09 16:26:40 2016 +0100 @@ -35,7 +35,6 @@ #include "../Core/Toolbox.h" #include "../Core/OrthancException.h" -#include "../Core/Uuid.h" #include "../Core/HttpServer/BufferHttpSender.h" #include "../Core/HttpServer/FilesystemHttpSender.h" #include "../Core/HttpServer/HttpStreamTranscoder.h"
--- a/UnitTestsSources/UnitTestsMain.cpp Wed Nov 09 16:16:26 2016 +0100 +++ b/UnitTestsSources/UnitTestsMain.cpp Wed Nov 09 16:26:40 2016 +0100 @@ -41,8 +41,8 @@ #include "../Core/HttpServer/HttpToolbox.h" #include "../Core/Logging.h" #include "../Core/OrthancException.h" +#include "../Core/TemporaryFile.h" #include "../Core/Toolbox.h" -#include "../Core/Uuid.h" #include "../OrthancServer/OrthancInitialization.h"