3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
8 * Full author contact details are available in file CREDITS.
15 #include "support/FileName.h"
16 #include "support/lyxlib.h"
18 #ifdef HAVE_SYS_STAT_H
19 # include <sys/stat.h>
21 #ifdef HAVE_SYS_TYPES_H
22 # include <sys/types.h>
35 bool chmod(FileName const & file, unsigned long int mode)
37 #if defined (HAVE_CHMOD) && defined (HAVE_MODE_T)
38 if (::chmod(file.toFilesystemEncoding().c_str(), mode_t(mode)) != 0)
41 // FIXME: "File permissions are ignored on this system."
47 bool copy(FileName const & from, FileName const & to, unsigned long int mode)
49 ifstream ifs(from.toFilesystemEncoding().c_str(), ios::binary | ios::in);
53 if (mode != (unsigned long int)-1) {
54 ofstream ofs(to.toFilesystemEncoding().c_str(),
55 ios::binary | ios::out | ios::trunc);
59 if (!support::chmod(to, mode))
63 ofstream ofs(to.toFilesystemEncoding().c_str(),
64 ios::binary | ios::out | ios::trunc);
72 } // namespace support