From b246ba02fdfff2635d156492e50f320de13e2ba2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Mon, 31 Jan 2005 19:31:11 +0000 Subject: [PATCH] Asgers Win32 changes to fs_extras git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9561 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/support/ChangeLog | 8 ++++++-- src/support/fs_extras.C | 30 +++++++++++++++++++++++++++++- src/support/package.C.in | 2 +- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/support/ChangeLog b/src/support/ChangeLog index 85a02b2a86..297aeb5479 100644 --- a/src/support/ChangeLog +++ b/src/support/ChangeLog @@ -1,3 +1,7 @@ +2005-01-31 Lars Gullik Bjonnes + + * fs_extras.C: add changes from Asgers Win32 patch. + 2005-01-31 Asger Ottar Alstrup * chdir.C (chdir): @@ -9,12 +13,12 @@ 2005-01-31 Lars Gullik Bjonnes - * Makefile.am (libsupport_la_SOURCES): remove rmdir.C + * Makefile.am (libsupport_la_SOURCES): remove rmdir.C * rmdir.C: delete file * lyxlib.h: remove rmdir decl - + 2005-01-31 Lars Gullik Bjonnes * .cvsignore: add package.C diff --git a/src/support/fs_extras.C b/src/support/fs_extras.C index e8a7afe0eb..5872134bb3 100644 --- a/src/support/fs_extras.C +++ b/src/support/fs_extras.C @@ -32,6 +32,11 @@ bool is_readable(path const & ph) #ifdef BOOST_POSIX return ::access(ph.string().c_str(), R_OK) == 0; #endif +#ifdef BOOST_WINDOWS + DWORD const attr = ::GetFileAttributes(ph.string().c_str()); + return attr != INVALID_FILE_ATTRIBUTES && + (attr & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY; +#endif } @@ -40,6 +45,16 @@ bool is_writable(path const & ph) #ifdef BOOST_POSIX return ::access(ph.string().c_str(), W_OK) == 0; #endif +#ifdef BOOST_WINDOWS + DWORD const attr = ::GetFileAttributes(ph.string().c_str()); + if (attr != INVALID_FILE_ATTRIBUTES && + (attr & FILE_ATTRIBUTE_READONLY) != 0) { + // Read-only - no write access + return false; + } + return attr != INVALID_FILE_ATTRIBUTES && + (attr & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY; +#endif } @@ -48,6 +63,11 @@ bool is_readonly(path const & ph) #ifdef BOOST_POSIX return is_readable(ph) && !is_writable(ph); #endif +#ifdef BOOST_WINDOWS + DWORD const attr = ::GetFileAttributes(ph.string().c_str()); + return (attr != INVALID_FILE_ATTRIBUTES + && (attr & FILE_ATTRIBUTE_READONLY)); +#endif } @@ -116,8 +136,16 @@ void copy_file(path const & source, path const & target, bool noclobber) source, target, fs::detail::system_error_code())); #endif +#ifdef BOOST_WINDOWS + if (::CopyFile(source.string().c_str(), target.string().c_str(), !noclobber) == 0) { + boost::throw_exception( + filesystem_error( + "boost::filesystem::copy_file", + source, target, + fs::detail::system_error_code())); + } +#endif } - } } diff --git a/src/support/package.C.in b/src/support/package.C.in index f87537022e..70a5e2b99f 100644 --- a/src/support/package.C.in +++ b/src/support/package.C.in @@ -662,7 +662,7 @@ bool check_env_var_dir(string const & dir, // translation. string const fmt = _("Invalid %1$s environment variable.\n%2$s is not a directory."); - + lyxerr << bformat(fmt, env_var, dir) << std::endl; } -- 2.39.2