Changeset 3284


Ignore:
Timestamp:
Jul 9, 2014, 7:38:58 AM (9 years ago)
Author:
Peter
Message:

fixes #804

Location:
branches/0.12-stable
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/0.12-stable/NEWS

    r3275 r3284  
    99  - Aligner(double, double) is now explicit (see r3207)
    1010  - GetlineIterator(istream&, char) is now explicit (see r3148)
     11  - rename(2) and remove(1) are now implemented (bug #804)
    1112
    1213  A complete list of closed tickets can be found here [[br]]
  • branches/0.12-stable/test/utility.cc

    r3210 r3284  
    5858void test_fnmatch(test::Suite& suite);
    5959bool test_fnmatch(bool, std::string, std::string);
     60void test_remove(test::Suite& suite);
     61void test_rename(test::Suite& suite);
    6062void test_replace(test::Suite& suite);
    6163
     
    218220  test_dirname(suite);
    219221  test_fnmatch(suite);
     222  test_remove(suite);
     223  test_rename(suite);
    220224  test_replace(suite);
    221225
     
    648652
    649653
     654void test_remove(test::Suite& suite)
     655{
     656  // at least test linking
     657  if (false)
     658    utility::remove("foo");
     659}
     660
     661
     662void test_rename(test::Suite& suite)
     663{
     664  // at least test linking
     665  if (false)
     666    utility::rename("foo", "bar");
     667}
     668
     669
    650670void test_replace(test::Suite& suite)
    651671{
  • branches/0.12-stable/yat/utility/utility.cc

    r3114 r3284  
    183183    mkdir_p(dirname(dir), mode);
    184184    mkdir(dir, mode);
     185  }
     186
     187
     188  void remove(const std::string& fn)
     189  {
     190    if (::remove(fn.c_str())) {
     191      std::string msg("remove: ");
     192      msg += fn;
     193      throw errno_error(msg);
     194    }
     195  }
     196
     197
     198  void rename(const std::string& from, const std::string& to)
     199  {
     200    if (::rename(from.c_str(), to.c_str())) {
     201      std::stringstream ss;
     202      ss << "rename" << from << " to " << to << ": ";
     203      throw errno_error(ss.str());
     204    }
    185205  }
    186206
  • branches/0.12-stable/yat/utility/utility.h

    r3188 r3284  
    361361     \see http://linux.die.net/man/3/remove
    362362
    363      \since New in yat 0.10
     363     \since New in yat 0.12
    364364   */
    365365  void remove(const std::string& fn);
     
    371371     \see http://linux.die.net/man/3/rename
    372372
    373      \since New in yat 0.10
    374    */
    375   void rename(const std::string& from, const std::string to);
     373     \since New in yat 0.12
     374   */
     375  void rename(const std::string& from, const std::string& to);
    376376
    377377  /**
Note: See TracChangeset for help on using the changeset viewer.