copy_file.cpp 595 B

123456789101112131415161718192021222324
  1. //
  2. // $Id$
  3. //
  4. #include<__vic/fs.h>
  5. #include<__vic/posix/file.h>
  6. #include<__vic/throw_errno.h>
  7. namespace __vic {
  8. void write_fd_to_file(int , const char * , bool );
  9. //----------------------------------------------------------------------------
  10. void copy_file(const char *src_path, const char *dest_path, bool replace)
  11. {
  12. posix::file src(src_path, O_RDONLY);
  13. if(!src.is_open()) throw_errno("Cannot open input file");
  14. write_fd_to_file(src.handle(), dest_path, replace);
  15. src.close();
  16. }
  17. //----------------------------------------------------------------------------
  18. } // namespace