]> git.lyx.org Git - features.git/commitdiff
get rid of lyxlib.h:copy() and rename().
authorAbdelrazak Younes <younes@lyx.org>
Thu, 13 Dec 2007 12:03:55 +0000 (12:03 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Thu, 13 Dec 2007 12:03:55 +0000 (12:03 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22129 a592a061-630c-0410-9148-cb99ea01b6c8

development/scons/scons_manifest.py
src/Buffer.cpp
src/insets/InsetBibtex.cpp
src/insets/InsetGraphics.cpp
src/insets/InsetInclude.cpp
src/support/Makefile.am
src/support/copy.cpp [deleted file]
src/support/lyxlib.h
src/support/rename.cpp [deleted file]

index a133d9b13b909bc6d11bbf6faab733bec7b41808..2faeec1f533823f0880367baffa8607a41cd4081 100644 (file)
@@ -341,7 +341,6 @@ src_support_files = Split('''
     Timeout.cpp
     abort.cpp
     convert.cpp
-    copy.cpp
     debug.cpp
     docstream.cpp
     docstring.cpp
@@ -356,7 +355,6 @@ src_support_files = Split('''
     lyxtime.cpp
     mkdir.cpp
     os.cpp
-    rename.cpp
     socktools.cpp
     tempname.cpp
     unicode.cpp
index 53fc33454466a92c9d2bc81d5ee6083c40da60fe..ad4a0e92aba75aeded71a86b4dd84f85d34785b5 100644 (file)
@@ -845,7 +845,7 @@ bool Buffer::save() const
        } else {
                // Saving failed, so backup is not backup
                if (madeBackup)
-                       rename(backupName, d->filename);
+                       backupName.renameTo(d->filename);
                return false;
        }
 }
@@ -1989,7 +1989,7 @@ int AutoSaveBuffer::generateChild()
                if (!tmp_ret.empty()) {
                        buffer_.writeFile(tmp_ret);
                        // assume successful write of tmp_ret
-                       if (!rename(tmp_ret, fname_)) {
+                       if (!tmp_ret.renameTo(fname_)) {
                                failed = true;
                                // most likely couldn't move between
                                // filesystems unless write of tmp_ret
index 0c6ee63bb11ae04866aafee390cc7c603b184f0e..9f9d21398a5e1dbb7c95332a8ff3bec7d8b32d68 100644 (file)
@@ -179,7 +179,7 @@ int InsetBibtex::latex(Buffer const & buffer, odocstream & os,
                        FileName const out_file = makeAbsPath(database + ".bib",
                                        buffer.masterBuffer()->temppath());
 
-                       bool const success = copy(in_file, out_file);
+                       bool const success = in_file.copyTo(out_file);
                        if (!success) {
                                lyxerr << "Failed to copy '" << in_file
                                       << "' to '" << out_file << "'"
@@ -238,7 +238,7 @@ int InsetBibtex::latex(Buffer const & buffer, odocstream & os,
                        base = removeExtension(in_file.mangledFilename());
                        FileName const out_file(makeAbsPath(base + ".bst",
                                        buffer.masterBuffer()->temppath()));
-                       bool const success = copy(in_file, out_file);
+                       bool const success = in_file.copyTo(out_file);
                        if (!success) {
                                lyxerr << "Failed to copy '" << in_file
                                       << "' to '" << out_file << "'"
index 3b33d9957f5d3a0cfa62b1c9eb6a2166dd08790e..cfb602cb3c9e15921c025bce8e7158a6328c496e 100644 (file)
@@ -688,7 +688,7 @@ string const InsetGraphics::prepareFile(Buffer const & buf,
                        // the file format from the extension, so we must
                        // change it.
                        FileName const new_file = FileName(changeExtension(temp_file.absFilename(), ext));
-                       if (rename(temp_file, new_file)) {
+                       if (temp_file.renameTo(new_file)) {
                                temp_file = new_file;
                                output_file = changeExtension(output_file, ext);
                                source_file = FileName(changeExtension(source_file.absFilename(), ext));
index 6faf674efa510a058e7af681a8bf5f79e4551dae..b6a4f0bc6d2756e2cf3dd8550a087ab62b547e55 100644 (file)
@@ -475,7 +475,7 @@ int InsetInclude::latex(Buffer const & buffer, odocstream & os,
                unsigned long const checksum_out = writefile.checksum();
 
                if (checksum_in != checksum_out) {
-                       if (!copy(included_file, writefile)) {
+                       if (!included_file.copyTo(writefile)) {
                                // FIXME UNICODE
                                LYXERR(Debug::LATEX,
                                        to_utf8(bformat(_("Could not copy the file\n%1$s\n"
index e35f66abe018874db34750e5f6cd1c5a3eaddb1d..934d10051d20b0242d026b4a38c5322671ff0230 100644 (file)
@@ -44,7 +44,6 @@ liblyxsupport_la_SOURCES = \
        abort.cpp \
        convert.cpp \
        convert.h \
-       copy.cpp \
        copied_ptr.h \
        debug.cpp \
        debug.h \
@@ -87,7 +86,6 @@ liblyxsupport_la_SOURCES = \
        Package.cpp \
        Package.h \
        qstring_helpers.h \
-       rename.cpp \
        socktools.cpp \
        socktools.h \
        strfwd.h \
diff --git a/src/support/copy.cpp b/src/support/copy.cpp
deleted file mode 100644 (file)
index 0bf90ba..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * \file copy.cpp
- * 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 <fstream>
-
-#include "support/FileName.h"
-#include "support/lyxlib.h"
-
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-using namespace std;
-
-namespace lyx {
-namespace support {
-
-static bool chmod(FileName const & file, unsigned long int mode)
-{
-#if defined (HAVE_CHMOD) && defined (HAVE_MODE_T)
-       if (::chmod(file.toFilesystemEncoding().c_str(), mode_t(mode)) != 0)
-               return false;
-#else
-       // FIXME: "File permissions are ignored on this system."
-#endif
-       return true;
-}
-
-
-bool copy(FileName const & from, FileName const & to, unsigned long int mode)
-{
-       ifstream ifs(from.toFilesystemEncoding().c_str(), ios::binary | ios::in);
-       if (!ifs)
-               return false;
-
-       if (mode != (unsigned long int)-1) {
-               ofstream ofs(to.toFilesystemEncoding().c_str(),
-                       ios::binary | ios::out | ios::trunc);
-               if (!ofs)
-                       return false;
-               ofs.close();
-               if (!support::chmod(to, mode))
-                       return false;
-       }
-
-       ofstream ofs(to.toFilesystemEncoding().c_str(),
-                       ios::binary | ios::out | ios::trunc);
-       if (!ofs)
-               return false;
-
-       ofs << ifs.rdbuf();
-       return ofs.good();
-}
-
-} // namespace support
-} // namespace lyx
index 4e6cf32322c2b5c43ffa403bc001655b59e1ccde..4096bc8d94b31d2646560b5ddae794cce5b4e089 100644 (file)
@@ -26,14 +26,6 @@ namespace support {
 /// get the current working directory
 FileName const getcwd();
 
-/**
- * rename a file, returns false if it fails.
- * It can handle renames across partitions.
- */
-bool rename(FileName const & from, FileName const & to);
-/// copy a file, returns false it it fails
-bool copy(FileName const & from, FileName const & to,
-         unsigned long int mode = (unsigned long int)-1);
 /// FIXME: some point to this hmm ?
 int kill(int pid, int sig);
 /// FIXME: same here
diff --git a/src/support/rename.cpp b/src/support/rename.cpp
deleted file mode 100644 (file)
index 9a18e58..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * \file rename.cpp
- * 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 "support/lyxlib.h"
-#include "support/FileName.h"
-
-#include <cstdio>
-
-
-namespace lyx {
-namespace support {
-
-bool rename(FileName const & from, FileName const & to)
-{
-       if (::rename(from.toFilesystemEncoding().c_str(),
-                       to.toFilesystemEncoding().c_str()) != -1) 
-               return true;
-       if (!copy(from, to))
-               return false;
-       from.removeFile();
-       return true;
-}
-
-
-} // namespace support
-} // namespace lyx