Asgers Win32 changes to fs_extras

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9561 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2005-01-31 19:31:11 +00:00
parent 3f74d3dc9b
commit b246ba02fd
3 changed files with 36 additions and 4 deletions

View File

@ -1,3 +1,7 @@
2005-01-31 Lars Gullik Bjonnes <larsbj@gullik.net>
* fs_extras.C: add changes from Asgers Win32 patch.
2005-01-31 Asger Ottar Alstrup <aalstrup@laerdal.dk>
* chdir.C (chdir):
@ -9,12 +13,12 @@
2005-01-31 Lars Gullik Bjonnes <larsbj@gullik.net>
* 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 <larsbj@gullik.net>
* .cvsignore: add package.C

View File

@ -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
}
}
}

View File

@ -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;
}