[Saga-devel] saga SVN commit 3291: /trunk/adaptors/ssh/ssh_file/

amerzky at cct.lsu.edu amerzky at cct.lsu.edu
Thu Jan 15 06:35:24 CST 2009


User: amerzky
Date: 2009/01/15 06:35 AM

Modified:
 /trunk/adaptors/ssh/ssh_file/
  ssh_file_adaptor_dir_nsdir_impl.cpp

Log:
 fix cd

File Changes:

Directory: /trunk/adaptors/ssh/ssh_file/
========================================

File [modified]: ssh_file_adaptor_dir_nsdir_impl.cpp
Delta lines: +23 -6
===================================================================
--- trunk/adaptors/ssh/ssh_file/ssh_file_adaptor_dir_nsdir_impl.cpp	2009-01-15 12:33:23 UTC (rev 3290)
+++ trunk/adaptors/ssh/ssh_file/ssh_file_adaptor_dir_nsdir_impl.cpp	2009-01-15 12:35:16 UTC (rev 3291)
@@ -17,16 +17,33 @@
   void dir_cpi_impl::sync_change_dir (saga::impl::void_t & ret, 
                                       saga::url            name)
   {
-    // FIXME when leaving the mounted FS
-    try {
-      d_.change_dir (sshfs_->translate (name));
+    saga::url save = d_.get_url ();
+
+    try 
+    {
+      // create target URL (gets normalized);
+      saga::url tgt (d_.get_url ());
+      tgt.set_path  (d_.get_url ().get_path () + "/" + name.get_string ());
+
+      d_.change_dir (tgt);
+    }
+    catch ( const saga::exception & e )
+    {
+      // if we can't change the dir, simply forward the exception
+      std::cout << " +++ " << u_ << std::endl;
+      throw e;
+    }
+
+    try 
+    {
       u_ = sshfs_->translate_back (d_.get_url ());
     }
     catch ( const saga::exception & e )
     {
-      // revert cd
-      d_.change_dir (u_);
-      throw;
+      // the cd appearently moved us outside the mounted name space, thus
+      // translate_back failed.  We refuse to continue.
+      d_.change_dir (save);
+      SAGA_ADAPTOR_THROW ("Target is outside of mounted namespace directory", saga::NoSuccess);
     }
   }
 



More information about the saga-devel mailing list