]> git.lyx.org Git - lyx.git/blobdiff - src/support/copy.C
* src/text2.C: deleteEmptyParagraphMechanism(): fix a crash in
[lyx.git] / src / support / copy.C
index ceb2db196800006519a88b3be374f39fa484eae9..9ed6246f417863ae0a1ac9a5085dbacbcdcc7766 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <fstream>
 
+#include "support/filename.h"
 #include "support/lyxlib.h"
 
 #ifdef HAVE_SYS_STAT_H
@@ -31,10 +32,10 @@ using std::ios;
 using std::string;
 
 
-bool lyx::support::chmod(string const & file, unsigned long int mode)
+bool lyx::support::chmod(FileName const & file, unsigned long int mode)
 {
-#ifdef HAVE_CHMOD
-       if (::chmod(file.c_str(), mode_t(mode)) != 0)
+#if defined (HAVE_CHMOD) && defined (HAVE_MODE_T)
+       if (::chmod(file.toFilesystemEncoding().c_str(), mode_t(mode)) != 0)
                return false;
 #else
 # ifdef WITH_WARNINGS
@@ -45,14 +46,14 @@ bool lyx::support::chmod(string const & file, unsigned long int mode)
 }
 
 
-bool lyx::support::copy(string const & from, string const & to, unsigned long int mode)
+bool lyx::support::copy(FileName const & from, FileName const & to, unsigned long int mode)
 {
-       ifstream ifs(from.c_str(), ios::binary | ios::in);
+       ifstream ifs(from.toFilesystemEncoding().c_str(), ios::binary | ios::in);
        if (!ifs)
                return false;
 
        if (mode != (unsigned long int)-1) {
-               ofstream ofs(to.c_str(), ios::binary | ios::out | ios::trunc);
+               ofstream ofs(to.toFilesystemEncoding().c_str(), ios::binary | ios::out | ios::trunc);
                if (!ofs)
                        return false;
                ofs.close();
@@ -60,7 +61,7 @@ bool lyx::support::copy(string const & from, string const & to, unsigned long in
                        return false;
        }
 
-       ofstream ofs(to.c_str(), ios::binary | ios::out | ios::trunc);
+       ofstream ofs(to.toFilesystemEncoding().c_str(), ios::binary | ios::out | ios::trunc);
        if (!ofs)
                return false;