lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [6319] Remove the problem identified 20151006T1248Z


From: Greg Chicares
Subject: [lmi-commits] [6319] Remove the problem identified 20151006T1248Z
Date: Tue, 06 Oct 2015 13:02:37 +0000

Revision: 6319
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=6319
Author:   chicares
Date:     2015-10-06 13:02:36 +0000 (Tue, 06 Oct 2015)
Log Message:
-----------
Remove the problem identified 20151006T1248Z

Modified Paths:
--------------
    lmi/trunk/path_utility.cpp
    lmi/trunk/path_utility.hpp
    lmi/trunk/path_utility_test.cpp

Modified: lmi/trunk/path_utility.cpp
===================================================================
--- lmi/trunk/path_utility.cpp  2015-10-06 12:48:17 UTC (rev 6318)
+++ lmi/trunk/path_utility.cpp  2015-10-06 13:02:36 UTC (rev 6319)
@@ -31,13 +31,13 @@
 #include "alert.hpp"
 #include "assert_lmi.hpp"
 #include "global_settings.hpp"
-#include "miscellany.hpp" // iso_8601_datestamp_terse()
+#include "miscellany.hpp"               // iso_8601_datestamp_terse()
 
 #include <boost/filesystem/convenience.hpp>
 #include <boost/filesystem/exception.hpp>
 #include <boost/filesystem/operations.hpp>
 
-#include <cctype>         // std::isalnum()
+#include <cctype>                       // std::isalnum()
 #include <exception>
 #include <iomanip>
 #include <sstream>
@@ -209,7 +209,7 @@
 /// fail a boost::filesystem name check.
 
 fs::path serial_file_path
-    (fs::path const&    exemplar
+    (fs::path    const& exemplar
     ,std::string const& personal_name
     ,int                serial_number
     ,std::string const& extension
@@ -245,7 +245,7 @@
 /// any, to the given extension. If the resulting file path already
 /// exists, then try to remove it. If that fails, then try to make the
 /// file path unique by inserting a "YYYYMMDDTHHMMSSZ" timestamp right
-/// before the extension: that should suffice because an end user can
+/// before the last dot: that should suffice because an end user can
 /// hardly run illustrations faster than once a second. If even that
 /// fails to establish the postcondition, then throw an exception.
 ///
@@ -260,12 +260,12 @@
 /// by another process as in the motivating example above.
 
 fs::path unique_filepath
-    (fs::path const&    original_filepath
-    ,std::string const& extension
+    (fs::path    const& original_filepath
+    ,std::string const& supplied_extension
     )
 {
     fs::path filepath(original_filepath);
-    filepath = fs::change_extension(filepath, extension);
+    filepath = fs::change_extension(filepath, supplied_extension);
     if(!fs::exists(filepath))
         {
         return filepath;
@@ -278,7 +278,8 @@
         }
     catch(std::exception const&)
         {
-        std::string basename = fs::basename(filepath);
+        std::string basename  = fs::basename (filepath);
+        std::string extension = fs::extension(filepath);
         basename += '-' + iso_8601_datestamp_terse() + extension;
         filepath = filepath.branch_path() / basename;
         if(fs::exists(filepath))
@@ -287,7 +288,7 @@
                 << "Cannot create unique file path from file name '"
                 << original_filepath
                 << "' with extension '"
-                << extension
+                << supplied_extension
                 << "'."
                 << LMI_FLUSH
                 ;

Modified: lmi/trunk/path_utility.hpp
===================================================================
--- lmi/trunk/path_utility.hpp  2015-10-06 12:48:17 UTC (rev 6318)
+++ lmi/trunk/path_utility.hpp  2015-10-06 13:02:36 UTC (rev 6319)
@@ -40,15 +40,15 @@
     );
 
 fs::path LMI_SO serial_file_path
-    (fs::path const&    exemplar
+    (fs::path    const& exemplar
     ,std::string const& personal_name
     ,int                serial_number
     ,std::string const& extension
     );
 
 fs::path LMI_SO unique_filepath
-    (fs::path const&    original_filepath
-    ,std::string const& extension
+    (fs::path    const& original_filepath
+    ,std::string const& supplied_extension
     );
 
 void LMI_SO validate_directory

Modified: lmi/trunk/path_utility_test.cpp
===================================================================
--- lmi/trunk/path_utility_test.cpp     2015-10-06 12:48:17 UTC (rev 6318)
+++ lmi/trunk/path_utility_test.cpp     2015-10-06 13:02:36 UTC (rev 6319)
@@ -212,14 +212,6 @@
     fs::path path4 = unique_filepath(fs::path(p), ".abc.def");
     BOOST_TEST(path3.string().size() == std::string(r).size());
     BOOST_TEST(path4.string().size() == std::string(s).size());
-// Temporary code to show a defect in the original implementation:
-std::cout
-  << r              << " " << std::string(r).size() << '\n'
-  << path3.string() << " " << path3.string().size() << '\n'
-  << s              << " " << std::string(s).size() << '\n'
-  << path4.string() << " " << path4.string().size() << '\n'
-  << std::flush
-  ;
 
     keep_open.close();
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]