]> git.lyx.org Git - lyx.git/blobdiff - src/support/copy.C
make "make distcheck" work
[lyx.git] / src / support / copy.C
index ed1fa9ea456a45afad3829646294add8f18e751d..cf51ce37b436c0c947d3cc2b7f51bf2b4a81eba7 100644 (file)
@@ -1,15 +1,36 @@
+/**
+ * \file copy.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Lars Gullik Bjønnes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
 #include <config.h>
 
-#include <stdio.h>
+#include <fstream>
 
 #include "support/lyxlib.h"
-#include "LString.h"
-#include "support/syscall.h"
-#include "support/filetools.h"
 
-bool lyx::copy(char const * from, char const * to)
+
+using std::ifstream;
+using std::ofstream;
+using std::ios;
+using std::string;
+
+
+bool lyx::support::copy(string const & from, string const & to)
 {
-       string command = "cp " + QuoteName(from) + " " + QuoteName(to);
-       return Systemcalls().startscript(Systemcalls::System,
-                                        command) == 0;
+       ifstream ifs(from.c_str(), ios::binary | ios::in);
+       if (!ifs)
+               return false;
+
+       ofstream ofs(to.c_str(), ios::binary | ios::out | ios::trunc);
+       if (!ofs)
+               return false;
+
+       ofs << ifs.rdbuf();
+       return ofs.good();
 }