Mercurial > hg > orthanc
comparison Core/Toolbox.cpp @ 50:a15e90e5d6fc
rename in code
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 05 Sep 2012 15:50:12 +0200 |
parents | 166664f0f860 |
children | c996319e90bc |
comparison
equal
deleted
inserted
replaced
49:e1a3ae0dadf3 | 50:a15e90e5d6fc |
---|---|
1 /** | 1 /** |
2 * Palantir - A Lightweight, RESTful DICOM Store | 2 * Palanthir - 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 "PalantirException.h" | 23 #include "PalanthirException.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 Palantir | 42 namespace Palanthir |
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 PalantirException("Unable to open a file"); | 128 throw PalanthirException("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 PalantirException("The path is not a regular file: " + path); | 153 throw PalanthirException("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 PalantirException(ErrorCode_UriSyntax); | 169 throw PalanthirException(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 PalantirException(ErrorCode_InexistentFile); | 304 throw PalanthirException(ErrorCode_InexistentFile); |
305 } | 305 } |
306 } | 306 } |
307 | 307 |
308 | 308 |
309 static char GetHexadecimalCharacter(uint8_t value) | 309 static char GetHexadecimalCharacter(uint8_t value) |