Applied patch [ 613433 ] Makes wxFN::Get/SetTimes work w/ Cygwin
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17429 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1616,23 +1616,7 @@ bool wxFileName::SetTimes(const wxDateTime *dtAccess,
|
|||||||
const wxDateTime *dtMod,
|
const wxDateTime *dtMod,
|
||||||
const wxDateTime *dtCreate)
|
const wxDateTime *dtCreate)
|
||||||
{
|
{
|
||||||
#if defined(__UNIX_LIKE__) || (defined(__DOS__) && defined(__WATCOMC__))
|
#if defined(__WIN32__)
|
||||||
if ( !dtAccess && !dtMod )
|
|
||||||
{
|
|
||||||
// can't modify the creation time anyhow, don't try
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if dtAccess or dtMod is not specified, use the other one (which must be
|
|
||||||
// non NULL because of the test above) for both times
|
|
||||||
utimbuf utm;
|
|
||||||
utm.actime = dtAccess ? dtAccess->GetTicks() : dtMod->GetTicks();
|
|
||||||
utm.modtime = dtMod ? dtMod->GetTicks() : dtAccess->GetTicks();
|
|
||||||
if ( utime(GetFullPath().fn_str(), &utm) == 0 )
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
#elif defined(__WIN32__)
|
|
||||||
wxFileHandle fh(GetFullPath(), wxFileHandle::Write);
|
wxFileHandle fh(GetFullPath(), wxFileHandle::Write);
|
||||||
if ( fh.IsOk() )
|
if ( fh.IsOk() )
|
||||||
{
|
{
|
||||||
@@ -1653,6 +1637,22 @@ bool wxFileName::SetTimes(const wxDateTime *dtAccess,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#elif defined(__UNIX_LIKE__) || (defined(__DOS__) && defined(__WATCOMC__))
|
||||||
|
if ( !dtAccess && !dtMod )
|
||||||
|
{
|
||||||
|
// can't modify the creation time anyhow, don't try
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if dtAccess or dtMod is not specified, use the other one (which must be
|
||||||
|
// non NULL because of the test above) for both times
|
||||||
|
utimbuf utm;
|
||||||
|
utm.actime = dtAccess ? dtAccess->GetTicks() : dtMod->GetTicks();
|
||||||
|
utm.modtime = dtMod ? dtMod->GetTicks() : dtAccess->GetTicks();
|
||||||
|
if ( utime(GetFullPath().fn_str(), &utm) == 0 )
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
#else // other platform
|
#else // other platform
|
||||||
#endif // platforms
|
#endif // platforms
|
||||||
|
|
||||||
@@ -1685,20 +1685,7 @@ bool wxFileName::GetTimes(wxDateTime *dtAccess,
|
|||||||
wxDateTime *dtMod,
|
wxDateTime *dtMod,
|
||||||
wxDateTime *dtCreate) const
|
wxDateTime *dtCreate) const
|
||||||
{
|
{
|
||||||
#if defined(__UNIX_LIKE__) || defined(__WXMAC__) || (defined(__DOS__) && defined(__WATCOMC__))
|
#if defined(__WIN32__)
|
||||||
wxStructStat stBuf;
|
|
||||||
if ( wxStat( GetFullPath().c_str(), &stBuf) == 0 )
|
|
||||||
{
|
|
||||||
if ( dtAccess )
|
|
||||||
dtAccess->Set(stBuf.st_atime);
|
|
||||||
if ( dtMod )
|
|
||||||
dtMod->Set(stBuf.st_mtime);
|
|
||||||
if ( dtCreate )
|
|
||||||
dtCreate->Set(stBuf.st_ctime);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
#elif defined(__WIN32__)
|
|
||||||
wxFileHandle fh(GetFullPath(), wxFileHandle::Read);
|
wxFileHandle fh(GetFullPath(), wxFileHandle::Read);
|
||||||
if ( fh.IsOk() )
|
if ( fh.IsOk() )
|
||||||
{
|
{
|
||||||
@@ -1719,6 +1706,19 @@ bool wxFileName::GetTimes(wxDateTime *dtAccess,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#elif defined(__UNIX_LIKE__) || defined(__WXMAC__) || (defined(__DOS__) && defined(__WATCOMC__))
|
||||||
|
wxStructStat stBuf;
|
||||||
|
if ( wxStat( GetFullPath().c_str(), &stBuf) == 0 )
|
||||||
|
{
|
||||||
|
if ( dtAccess )
|
||||||
|
dtAccess->Set(stBuf.st_atime);
|
||||||
|
if ( dtMod )
|
||||||
|
dtMod->Set(stBuf.st_mtime);
|
||||||
|
if ( dtCreate )
|
||||||
|
dtCreate->Set(stBuf.st_ctime);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
#else // other platform
|
#else // other platform
|
||||||
#endif // platforms
|
#endif // platforms
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user