changeset 249:5694365ecb96

fixes for windows
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 05 Dec 2012 09:28:06 +0100
parents 2442033911d6
children f23318b11b39
files Core/Compression/HierarchicalZipWriter.cpp Core/Compression/HierarchicalZipWriter.h Core/Compression/ZipWriter.cpp Core/Compression/ZipWriter.h Core/RestApi/RestApi.cpp OrthancServer/OrthancRestApi.cpp UnitTests/Zip.cpp
diffstat 7 files changed, 39 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/Core/Compression/HierarchicalZipWriter.cpp	Tue Dec 04 17:49:37 2012 +0100
+++ b/Core/Compression/HierarchicalZipWriter.cpp	Wed Dec 05 09:28:06 2012 +0100
@@ -120,12 +120,12 @@
     }
   }
 
-  std::string HierarchicalZipWriter::Index::CreateFile(const char* name)
+  std::string HierarchicalZipWriter::Index::OpenFile(const char* name)
   {
     return GetCurrentDirectoryPath() + EnsureUniqueFilename(name);
   }
 
-  void HierarchicalZipWriter::Index::CreateDirectory(const char* name)
+  void HierarchicalZipWriter::Index::OpenDirectory(const char* name)
   {
     std::string d = EnsureUniqueFilename(name);
 
@@ -158,15 +158,15 @@
     writer_.Close();
   }
 
-  void HierarchicalZipWriter::CreateFile(const char* name)
+  void HierarchicalZipWriter::OpenFile(const char* name)
   {
-    std::string p = indexer_.CreateFile(name);
-    writer_.CreateFileInZip(p.c_str());
+    std::string p = indexer_.OpenFile(name);
+    writer_.OpenFile(p.c_str());
   }
 
-  void HierarchicalZipWriter::CreateDirectory(const char* name)
+  void HierarchicalZipWriter::OpenDirectory(const char* name)
   {
-    indexer_.CreateDirectory(name);
+    indexer_.OpenDirectory(name);
   }
 
   void HierarchicalZipWriter::CloseDirectory()
--- a/Core/Compression/HierarchicalZipWriter.h	Tue Dec 04 17:49:37 2012 +0100
+++ b/Core/Compression/HierarchicalZipWriter.h	Wed Dec 05 09:28:06 2012 +0100
@@ -75,9 +75,9 @@
         return stack_.size() == 1;
       }
 
-      std::string CreateFile(const char* name);
+      std::string OpenFile(const char* name);
 
-      void CreateDirectory(const char* name);
+      void OpenDirectory(const char* name);
 
       void CloseDirectory();
 
@@ -102,9 +102,9 @@
       return writer_.GetCompressionLevel();
     }
 
-    void CreateFile(const char* name);
+    void OpenFile(const char* name);
 
-    void CreateDirectory(const char* name);
+    void OpenDirectory(const char* name);
 
     void CloseDirectory();
 
--- a/Core/Compression/ZipWriter.cpp	Tue Dec 04 17:49:37 2012 +0100
+++ b/Core/Compression/ZipWriter.cpp	Wed Dec 05 09:28:06 2012 +0100
@@ -136,7 +136,7 @@
     compressionLevel_ = level;
   }
 
-  void ZipWriter::CreateFileInZip(const char* path)
+  void ZipWriter::OpenFile(const char* path)
   {
     Open();
 
@@ -171,7 +171,7 @@
   {
     if (!hasFileInZip_)
     {
-      throw OrthancException("Call first CreateFileInZip()");
+      throw OrthancException("Call first OpenFile()");
     }
 
     const size_t maxBytesInAStep = std::numeric_limits<int32_t>::max();
--- a/Core/Compression/ZipWriter.h	Tue Dec 04 17:49:37 2012 +0100
+++ b/Core/Compression/ZipWriter.h	Wed Dec 05 09:28:06 2012 +0100
@@ -74,7 +74,7 @@
       return path_;
     }
 
-    void CreateFileInZip(const char* path);
+    void OpenFile(const char* path);
 
     void Write(const char* data, size_t length);
 
--- a/Core/RestApi/RestApi.cpp	Tue Dec 04 17:49:37 2012 +0100
+++ b/Core/RestApi/RestApi.cpp	Wed Dec 05 09:28:06 2012 +0100
@@ -32,6 +32,7 @@
 
 #include "RestApi.h"
 
+#include <stdlib.h>   // To define "_exit()" under Windows
 #include <glog/logging.h>
 
 namespace Orthanc
--- a/OrthancServer/OrthancRestApi.cpp	Tue Dec 04 17:49:37 2012 +0100
+++ b/OrthancServer/OrthancRestApi.cpp	Wed Dec 05 09:28:06 2012 +0100
@@ -373,7 +373,7 @@
         Json::Value study;
         if (context.GetIndex().LookupResource(study, patient["Studies"][i].asString(), ResourceType_Study))
         {
-          writer.CreateDirectory(study["MainDicomTags"]["StudyDescription"].asString().c_str());
+          writer.OpenDirectory(study["MainDicomTags"]["StudyDescription"].asString().c_str());
 
           for (size_t i = 0; i < study["Series"].size(); i++)
           {
@@ -382,14 +382,14 @@
             {
               std::string m = series["MainDicomTags"]["Modality"].asString();
               std::string s = series["MainDicomTags"]["SeriesDescription"].asString();
-              writer.CreateDirectory((m + " " + s).c_str());
+              writer.OpenDirectory((m + " " + s).c_str());
 
               for (size_t i = 0; i < series["Instances"].size(); i++)
               {
                 Json::Value instance;
                 if (context.GetIndex().LookupResource(instance, series["Instances"][i].asString(), ResourceType_Instance))
                 {
-                  writer.CreateFile(instance["MainDicomTags"]["SOPInstanceUID"].asString().c_str());
+                  writer.OpenFile(instance["MainDicomTags"]["SOPInstanceUID"].asString().c_str());
                 }
               }
 
--- a/UnitTests/Zip.cpp	Tue Dec 04 17:49:37 2012 +0100
+++ b/UnitTests/Zip.cpp	Wed Dec 05 09:28:06 2012 +0100
@@ -13,7 +13,7 @@
   Orthanc::ZipWriter w;
   w.SetOutputPath("hello.zip");
   w.Open();
-  w.CreateFileInZip("world/hello");
+  w.OpenFile("world/hello");
   w.Write("Hello world");
 }
 
@@ -39,28 +39,28 @@
   TEST(HierarchicalZipWriter, Index)
   {
     HierarchicalZipWriter::Index i;
-    ASSERT_EQ("hello", i.CreateFile("hello"));
-    ASSERT_EQ("hello-2", i.CreateFile("hello"));
-    ASSERT_EQ("coucou", i.CreateFile("coucou"));
-    ASSERT_EQ("hello-3", i.CreateFile("hello"));
+    ASSERT_EQ("hello", i.OpenFile("hello"));
+    ASSERT_EQ("hello-2", i.OpenFile("hello"));
+    ASSERT_EQ("coucou", i.OpenFile("coucou"));
+    ASSERT_EQ("hello-3", i.OpenFile("hello"));
 
-    i.CreateDirectory("coucou");
+    i.OpenDirectory("coucou");
 
-    ASSERT_EQ("coucou-2/world", i.CreateFile("world"));
-    ASSERT_EQ("coucou-2/world-2", i.CreateFile("world"));
+    ASSERT_EQ("coucou-2/world", i.OpenFile("world"));
+    ASSERT_EQ("coucou-2/world-2", i.OpenFile("world"));
 
-    i.CreateDirectory("world");
+    i.OpenDirectory("world");
   
-    ASSERT_EQ("coucou-2/world-3/hello", i.CreateFile("hello"));
-    ASSERT_EQ("coucou-2/world-3/hello-2", i.CreateFile("hello"));
+    ASSERT_EQ("coucou-2/world-3/hello", i.OpenFile("hello"));
+    ASSERT_EQ("coucou-2/world-3/hello-2", i.OpenFile("hello"));
 
     i.CloseDirectory();
 
-    ASSERT_EQ("coucou-2/world-4", i.CreateFile("world"));
+    ASSERT_EQ("coucou-2/world-4", i.OpenFile("world"));
 
     i.CloseDirectory();
 
-    ASSERT_EQ("coucou-3", i.CreateFile("coucou"));
+    ASSERT_EQ("coucou-3", i.OpenFile("coucou"));
 
     ASSERT_THROW(i.CloseDirectory(), OrthancException);
   }
@@ -83,28 +83,28 @@
   w.SetCompressionLevel(0);
 
   // Inside "/"
-  w.CreateFile("hello");
+  w.OpenFile("hello");
   w.Write(SPACES + "hello\n");
-  w.CreateFile("hello");
+  w.OpenFile("hello");
   w.Write(SPACES + "hello-2\n");
-  w.CreateDirectory("hello");
+  w.OpenDirectory("hello");
 
   // Inside "/hello-3"
-  w.CreateFile("hello");
+  w.OpenFile("hello");
   w.Write(SPACES + "hello\n");
-  w.CreateDirectory("hello");
+  w.OpenDirectory("hello");
 
   w.SetCompressionLevel(9);
 
   // Inside "/hello-3/hello-2"
-  w.CreateFile("hello");
+  w.OpenFile("hello");
   w.Write(SPACES + "hello\n");
-  w.CreateFile("hello");
+  w.OpenFile("hello");
   w.Write(SPACES + "hello-2\n");
   w.CloseDirectory();
 
   // Inside "/hello-3"
-  w.CreateFile("hello");
+  w.OpenFile("hello");
   w.Write(SPACES + "hello-3\n");
 
   /**