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 lyx::support::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)
42 # warning "File permissions are ignored on this system."
49 bool lyx::support::copy(FileName const & from, FileName const & to, unsigned long int mode)
51 ifstream ifs(from.toFilesystemEncoding().c_str(), ios::binary | ios::in);
55 if (mode != (unsigned long int)-1) {
56 ofstream ofs(to.toFilesystemEncoding().c_str(), ios::binary | ios::out | ios::trunc);
60 if (!support::chmod(to, mode))
64 ofstream ofs(to.toFilesystemEncoding().c_str(), ios::binary | ios::out | ios::trunc);