Changeset 3746


Ignore:
Timestamp:
Aug 13, 2018, 8:43:34 AM (4 years ago)
Author:
Peter
Message:

new wrapper function around posix function 'symlink'

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/utility.cc

    r3698 r3746  
    6363void test_rename(test::Suite& suite);
    6464void test_replace(test::Suite& suite);
     65void test_symlink(test::Suite& suite);
    6566
    6667template<typename InputIterator, typename Key>
     
    238239  test_rename(suite);
    239240  test_replace(suite);
     241  test_symlink(suite);
    240242  test_ticket842(suite);
    241243
     
    783785
    784786
     787void test_symlink(test::Suite& suite)
     788{
     789  // at least test function links
     790  if (false)
     791    utility::symlink("/from/to/path", "my/symlink");
     792}
     793
     794
    785795void test_ticket842(test::Suite& suite)
    786796{
  • trunk/yat/utility/utility.cc

    r3730 r3746  
    246246
    247247
     248  void symlink(const std::string& path1, const std::string& path2)
     249  {
     250    if (::symlink(path1.c_str(), path2.c_str())) {
     251      std::string msg("symlink: '");
     252      msg += path1;
     253      msg += "' -> '";
     254      msg += path2;
     255      msg += "': ";
     256      throw errno_error(msg);
     257    }
     258  }
     259
     260
    248261}}} // end of namespace utility, yat and thep
  • trunk/yat/utility/utility.h

    r3730 r3746  
    406406  template<typename Iterator>
    407407  double sum_weight(Iterator first, Iterator last);
     408
     409  /**
     410     same as C function symlink but throws errno_error at failure
     411
     412     Creates a symbolic link called \a path2 that contains the string
     413     pointed to by \a path1
     414
     415     \see http://linux.die.net/man/3/symlink
     416
     417     \since New in yat 0.16
     418   */
     419  void symlink(const std::string& path1, const std::string& path2);
    408420
    409421/// \cond IGNORE_DOXYGEN
Note: See TracChangeset for help on using the changeset viewer.