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>
30 bool chmod(FileName const & file, unsigned long int mode)
32 #if defined (HAVE_CHMOD) && defined (HAVE_MODE_T)
33 if (::chmod(file.toFilesystemEncoding().c_str(), mode_t(mode)) != 0)
36 // FIXME: "File permissions are ignored on this system."
42 bool copy(FileName const & from, FileName const & to, unsigned long int mode)
44 ifstream ifs(from.toFilesystemEncoding().c_str(), ios::binary | ios::in);
48 if (mode != (unsigned long int)-1) {
49 ofstream ofs(to.toFilesystemEncoding().c_str(),
50 ios::binary | ios::out | ios::trunc);
54 if (!support::chmod(to, mode))
58 ofstream ofs(to.toFilesystemEncoding().c_str(),
59 ios::binary | ios::out | ios::trunc);
67 } // namespace support