summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
a12bd55)
wxFileHandle helper class used in wxFileName::SetTimes() under MSW modified
the file access time by setting it to the current time because it opened the
file in a wrong mode.
Closes #10567.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62705
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
};
wxFileHandle(const wxString& filename, OpenMode mode, int flags = 0)
{
};
wxFileHandle(const wxString& filename, OpenMode mode, int flags = 0)
{
+ // be careful and use FILE_{READ,WRITE}_ATTRIBUTES here instead of the
+ // usual GENERIC_{READ,WRITE} as we don't want the file access time to
+ // be changed when we open it because this class is used for setting
+ // access time (see #10567)
m_hFile = ::CreateFile
(
filename.fn_str(), // name
m_hFile = ::CreateFile
(
filename.fn_str(), // name
- mode == Read ? GENERIC_READ // access mask
- : GENERIC_WRITE,
+ mode == ReadAttr ? FILE_READ_ATTRIBUTES // access mask
+ : FILE_WRITE_ATTRIBUTES,
FILE_SHARE_READ | // sharing mode
FILE_SHARE_WRITE, // (allow everything)
NULL, // no secutity attr
FILE_SHARE_READ | // sharing mode
FILE_SHARE_WRITE, // (allow everything)
NULL, // no secutity attr
if ( m_hFile == INVALID_HANDLE_VALUE )
{
if ( m_hFile == INVALID_HANDLE_VALUE )
{
+ if ( mode == ReadAttr )
{
wxLogSysError(_("Failed to open '%s' for reading"),
filename.c_str());
{
wxLogSysError(_("Failed to open '%s' for reading"),
filename.c_str());
- wxFileHandle fh(path, wxFileHandle::Write, flags);
+ wxFileHandle fh(path, wxFileHandle::WriteAttr, flags);
if ( fh.IsOk() )
{
if ( ::SetFileTime(fh,
if ( fh.IsOk() )
{
if ( ::SetFileTime(fh,
- wxFileHandle fh(GetFullPath(), wxFileHandle::Read);
+ wxFileHandle fh(GetFullPath(), wxFileHandle::ReadAttr);
if ( fh.IsOk() )
{
ok = ::GetFileTime(fh,
if ( fh.IsOk() )
{
ok = ::GetFileTime(fh,
// TODO
return wxInvalidSize;
#elif defined(__WIN32__)
// TODO
return wxInvalidSize;
#elif defined(__WIN32__)
- wxFileHandle f(filename, wxFileHandle::Read);
+ wxFileHandle f(filename, wxFileHandle::ReadAttr);
if (!f.IsOk())
return wxInvalidSize;
if (!f.IsOk())
return wxInvalidSize;