[Saga-devel] saga SVN commit 3280: /trunk/adaptors/default/file/

hkaiser at cct.lsu.edu hkaiser at cct.lsu.edu
Wed Jan 14 14:43:14 CST 2009


User: hkaiser
Date: 2009/01/14 02:43 PM

Modified:
 /trunk/adaptors/default/file/
  default_dir.cpp

Log:
 Fixed #319

File Changes:

Directory: /trunk/adaptors/default/file/
========================================

File [modified]: default_dir.cpp
Delta lines: +20 -49
===================================================================
--- trunk/adaptors/default/file/default_dir.cpp	2009-01-14 19:01:48 UTC (rev 3279)
+++ trunk/adaptors/default/file/default_dir.cpp	2009-01-14 20:43:12 UTC (rev 3280)
@@ -91,56 +91,20 @@
         }
         else
         {
-            if (!fs::create_directory (path)) {
+            try {
+                if (!fs::create_directory (path)) {
+                    SAGA_ADAPTOR_THROW(path.string() + 
+                      ": couldn't create the directory", saga::DoesNotExist);
+                }
+            }
+            catch (boost::system::system_error const& e) {
                 SAGA_ADAPTOR_THROW(path.string() + 
-                ": couldn't create the directory", saga::DoesNotExist);
+                    ": couldn't create the directory (" + e.what() + ")", 
+                    saga::DoesNotExist);
             }
         }
     }
 
-// #if !defined(SAGA_WINDOWS)
-// 
-//     std::string path_comp = dir_url.get_path();
-//     
-//     // A relative SAGA path MUST start with ./ or ../ (./tmp/)
-//     // A relative boost::fs path can start without a / (tmp/)
-//     
-//     int idx = path_comp.find("./");
-//     if( idx == 0 )
-//     { 
-//         // the path is relative: ./
-//         char buf[MAX_PATH+1];
-//         getcwd (buf, MAX_PATH);
-//         path_comp = std::string(buf) + "/" + path_comp;
-//     } 
-//     else if( idx == 1 )
-//     { 
-//         // the path is relative: ../
-//     }   
-//     else
-//     {
-//         // the path is absolute - we have to make sure that boost::fs 
-//         // understands it.
-//         int idx = path_comp.find("/");
-//         if( idx != 0 )
-//         path_comp.insert(0, "/");  
-//     }
-//     
-//     fs::path modified_path (path_comp, fs::native);
-//     modified_path.normalize();
-//     
-//     //THIS IS REALLY NASTY! It replaces the whole URL with just the path component.
-//     //Other adaptors that depend on a hostname component dont't like it ;-)
-//     //
-//     //data->location_ = modified_path.string();
-//     //
-//     //...better this way:
-//     //
-//     dir_url.set_path(modified_path.string());
-//     data->location_ = dir_url.get_url();
-//     
-// #endif // #if !defined(SAGA_WINDOWS)
-
     // make sure directory exists
     if ((data->mode_ & saga::filesystem::Create ||
          data->mode_ & saga::filesystem::CreateParents) && 
@@ -157,10 +121,17 @@
     {    
       // create directory, if needed
       if (data->mode_ & saga::filesystem::Create) {
-        if (!fs::create_directory (path)) {
-          SAGA_ADAPTOR_THROW(path.string () + 
-            ": couldn't create the directory", saga::DoesNotExist);
-        }
+            try {
+                if (!fs::create_directory (path)) {
+                      SAGA_ADAPTOR_THROW(path.string () + 
+                        ": couldn't create the directory", saga::DoesNotExist);
+                }
+            }
+            catch (boost::system::system_error const& e) {
+                SAGA_ADAPTOR_THROW(path.string () + 
+                  ": couldn't create the directory (" + e.what() + ")", 
+                  saga::DoesNotExist);
+            }
       }
       else if ( (data->mode_ & saga::filesystem::CreateParents) && ! fs::create_directories (path)) {
         SAGA_ADAPTOR_THROW(path.string () + 



More information about the saga-devel mailing list