implement SetTimes() for directories too under MSW [backport of r58153 from trunk] (closes #10250)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@60030 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -106,6 +106,8 @@ All (GUI):
|
|||||||
wxMSW:
|
wxMSW:
|
||||||
|
|
||||||
- Fixed generation of wxEVT_CHAR_HOOK events.
|
- Fixed generation of wxEVT_CHAR_HOOK events.
|
||||||
|
- Implement wxFileName::SetTimes() for directories (Steve Lamerton).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
2.8.10:
|
2.8.10:
|
||||||
@@ -181,7 +183,6 @@ wxMSW:
|
|||||||
|
|
||||||
|
|
||||||
wxMSW/CE:
|
wxMSW/CE:
|
||||||
|
|
||||||
- Don't hardcode the menu bar height (Michele Spighi).
|
- Don't hardcode the menu bar height (Michele Spighi).
|
||||||
|
|
||||||
wxGTK:
|
wxGTK:
|
||||||
|
@@ -158,7 +158,7 @@ public:
|
|||||||
Write
|
Write
|
||||||
};
|
};
|
||||||
|
|
||||||
wxFileHandle(const wxString& filename, OpenMode mode)
|
wxFileHandle(const wxString& filename, OpenMode mode, int flags = 0)
|
||||||
{
|
{
|
||||||
m_hFile = ::CreateFile
|
m_hFile = ::CreateFile
|
||||||
(
|
(
|
||||||
@@ -169,7 +169,7 @@ public:
|
|||||||
FILE_SHARE_WRITE, // (allow everything)
|
FILE_SHARE_WRITE, // (allow everything)
|
||||||
NULL, // no secutity attr
|
NULL, // no secutity attr
|
||||||
OPEN_EXISTING, // creation disposition
|
OPEN_EXISTING, // creation disposition
|
||||||
0, // no flags
|
flags, // flags
|
||||||
NULL // no template file
|
NULL // no template file
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -2158,32 +2158,43 @@ bool wxFileName::SetTimes(const wxDateTime *dtAccess,
|
|||||||
const wxDateTime *dtCreate)
|
const wxDateTime *dtCreate)
|
||||||
{
|
{
|
||||||
#if defined(__WIN32__)
|
#if defined(__WIN32__)
|
||||||
|
FILETIME ftAccess, ftCreate, ftWrite;
|
||||||
|
|
||||||
|
if ( dtCreate )
|
||||||
|
ConvertWxToFileTime(&ftCreate, *dtCreate);
|
||||||
|
if ( dtAccess )
|
||||||
|
ConvertWxToFileTime(&ftAccess, *dtAccess);
|
||||||
|
if ( dtMod )
|
||||||
|
ConvertWxToFileTime(&ftWrite, *dtMod);
|
||||||
|
|
||||||
|
wxString path;
|
||||||
|
int flags;
|
||||||
if ( IsDir() )
|
if ( IsDir() )
|
||||||
{
|
{
|
||||||
// VZ: please let me know how to do this if you can
|
if ( wxGetOsVersion() == wxOS_WINDOWS_9X )
|
||||||
wxFAIL_MSG( _T("SetTimes() not implemented for the directories") );
|
{
|
||||||
|
wxLogError(_("Setting directory access times is not supported under this OS version"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
path = GetPath();
|
||||||
|
flags = FILE_FLAG_BACKUP_SEMANTICS;
|
||||||
}
|
}
|
||||||
else // file
|
else // file
|
||||||
{
|
{
|
||||||
wxFileHandle fh(GetFullPath(), wxFileHandle::Write);
|
path = GetFullPath();
|
||||||
if ( fh.IsOk() )
|
flags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxFileHandle fh(path, wxFileHandle::Write, flags);
|
||||||
|
if ( fh.IsOk() )
|
||||||
|
{
|
||||||
|
if ( ::SetFileTime(fh,
|
||||||
|
dtCreate ? &ftCreate : NULL,
|
||||||
|
dtAccess ? &ftAccess : NULL,
|
||||||
|
dtMod ? &ftWrite : NULL) )
|
||||||
{
|
{
|
||||||
FILETIME ftAccess, ftCreate, ftWrite;
|
return true;
|
||||||
|
|
||||||
if ( dtCreate )
|
|
||||||
ConvertWxToFileTime(&ftCreate, *dtCreate);
|
|
||||||
if ( dtAccess )
|
|
||||||
ConvertWxToFileTime(&ftAccess, *dtAccess);
|
|
||||||
if ( dtMod )
|
|
||||||
ConvertWxToFileTime(&ftWrite, *dtMod);
|
|
||||||
|
|
||||||
if ( ::SetFileTime(fh,
|
|
||||||
dtCreate ? &ftCreate : NULL,
|
|
||||||
dtAccess ? &ftAccess : NULL,
|
|
||||||
dtMod ? &ftWrite : NULL) )
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined(__UNIX_LIKE__) || (defined(__DOS__) && defined(__WATCOMC__))
|
#elif defined(__UNIX_LIKE__) || (defined(__DOS__) && defined(__WATCOMC__))
|
||||||
|
Reference in New Issue
Block a user