From 2e34b2876af1e1716b884f30ee080da96054373c Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Thu, 13 Dec 2007 11:24:10 +0000 Subject: [PATCH] get rid of lyxlib.h:chmod. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22126 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ConverterCache.cpp | 2 +- src/support/FileName.cpp | 7 +++++-- src/support/copy.cpp | 2 +- src/support/lyxlib.h | 3 +-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ConverterCache.cpp b/src/ConverterCache.cpp index d1d16c058c..ae9e9d16a9 100644 --- a/src/ConverterCache.cpp +++ b/src/ConverterCache.cpp @@ -169,7 +169,7 @@ void ConverterCache::Impl::writeIndex() FileName const index(addName(cache_dir.absFilename(), "index")); ofstream os(index.toFilesystemEncoding().c_str()); os.close(); - if (!chmod(index, 0600)) + if (!index.changePermission(0600)) return; os.open(index.toFilesystemEncoding().c_str()); CacheType::iterator it1 = cache.begin(); diff --git a/src/support/FileName.cpp b/src/support/FileName.cpp index 2fa0ecfa22..119b51a70d 100644 --- a/src/support/FileName.cpp +++ b/src/support/FileName.cpp @@ -157,10 +157,13 @@ bool FileName::changePermission(unsigned long int mode) const return false; } - if (!chmod(*this, mode)) { - LYXERR0("File " << *this << " cannot be changed to " << mode << " mode!"); +#if defined (HAVE_CHMOD) && defined (HAVE_MODE_T) + if (::chmod(file.toFilesystemEncoding().c_str(), mode_t(mode)) != 0) { + LYXERR0("File " << *this << ": cannot change permission to " + << mode << "."); return false; } +#endif return true; } diff --git a/src/support/copy.cpp b/src/support/copy.cpp index 3c7c43ad56..0bf90ba9ba 100644 --- a/src/support/copy.cpp +++ b/src/support/copy.cpp @@ -27,7 +27,7 @@ using namespace std; namespace lyx { namespace support { -bool chmod(FileName const & file, unsigned long int mode) +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) diff --git a/src/support/lyxlib.h b/src/support/lyxlib.h index b7952d2868..4e6cf32322 100644 --- a/src/support/lyxlib.h +++ b/src/support/lyxlib.h @@ -25,8 +25,7 @@ namespace support { /// get the current working directory FileName const getcwd(); -/// Change file permissions -bool chmod(FileName const & file, unsigned long int mode); + /** * rename a file, returns false if it fails. * It can handle renames across partitions.