comparison Core/Toolbox.cpp @ 59:c996319e90bc orthanc-renaming

renaming in Core
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 16 Sep 2012 09:28:56 +0200
parents a15e90e5d6fc
children de8a5329b069
comparison
equal deleted inserted replaced
58:6da7fc87efaa 59:c996319e90bc
1 /** 1 /**
2 * Palanthir - A Lightweight, RESTful DICOM Store 2 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege, 3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege,
4 * Belgium 4 * Belgium
5 * 5 *
6 * This program is free software: you can redistribute it and/or 6 * This program is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as 7 * modify it under the terms of the GNU General Public License as
18 **/ 18 **/
19 19
20 20
21 #include "Toolbox.h" 21 #include "Toolbox.h"
22 22
23 #include "PalanthirException.h" 23 #include "OrthancException.h"
24 24
25 #include <string.h> 25 #include <string.h>
26 #include <boost/filesystem.hpp> 26 #include <boost/filesystem.hpp>
27 #include <boost/filesystem/fstream.hpp> 27 #include <boost/filesystem/fstream.hpp>
28 #include <algorithm> 28 #include <algorithm>
37 #endif 37 #endif
38 38
39 #include "../Resources/md5/md5.h" 39 #include "../Resources/md5/md5.h"
40 #include "../Resources/base64/base64.h" 40 #include "../Resources/base64/base64.h"
41 41
42 namespace Palanthir 42 namespace Orthanc
43 { 43 {
44 static bool finish; 44 static bool finish;
45 45
46 #if defined(_WIN32) 46 #if defined(_WIN32)
47 static BOOL WINAPI ConsoleControlHandler(DWORD dwCtrlType) 47 static BOOL WINAPI ConsoleControlHandler(DWORD dwCtrlType)
123 { 123 {
124 boost::filesystem::ifstream f; 124 boost::filesystem::ifstream f;
125 f.open(path, std::ifstream::in | std::ios::binary); 125 f.open(path, std::ifstream::in | std::ios::binary);
126 if (!f.good()) 126 if (!f.good())
127 { 127 {
128 throw PalanthirException("Unable to open a file"); 128 throw OrthancException("Unable to open a file");
129 } 129 }
130 130
131 // http://www.cplusplus.com/reference/iostream/istream/tellg/ 131 // http://www.cplusplus.com/reference/iostream/istream/tellg/
132 f.seekg(0, std::ios::end); 132 f.seekg(0, std::ios::end);
133 std::streamsize size = f.tellg(); 133 std::streamsize size = f.tellg();
148 if (boost::filesystem::exists(path)) 148 if (boost::filesystem::exists(path))
149 { 149 {
150 if (boost::filesystem::is_regular_file(path)) 150 if (boost::filesystem::is_regular_file(path))
151 boost::filesystem::remove(path); 151 boost::filesystem::remove(path);
152 else 152 else
153 throw PalanthirException("The path is not a regular file: " + path); 153 throw OrthancException("The path is not a regular file: " + path);
154 } 154 }
155 } 155 }
156 156
157 157
158 158
164 components.clear(); 164 components.clear();
165 165
166 if (uri.size() == 0 || 166 if (uri.size() == 0 ||
167 uri[0] != URI_SEPARATOR) 167 uri[0] != URI_SEPARATOR)
168 { 168 {
169 throw PalanthirException(ErrorCode_UriSyntax); 169 throw OrthancException(ErrorCode_UriSyntax);
170 } 170 }
171 171
172 // Count the number of slashes in the URI to make an assumption 172 // Count the number of slashes in the URI to make an assumption
173 // about the number of components in the URI 173 // about the number of components in the URI
174 unsigned int estimatedSize = 0; 174 unsigned int estimatedSize = 0;
299 { 299 {
300 return static_cast<uint64_t>(boost::filesystem::file_size(path)); 300 return static_cast<uint64_t>(boost::filesystem::file_size(path));
301 } 301 }
302 catch (boost::filesystem::filesystem_error) 302 catch (boost::filesystem::filesystem_error)
303 { 303 {
304 throw PalanthirException(ErrorCode_InexistentFile); 304 throw OrthancException(ErrorCode_InexistentFile);
305 } 305 }
306 } 306 }
307 307
308 308
309 static char GetHexadecimalCharacter(uint8_t value) 309 static char GetHexadecimalCharacter(uint8_t value)