diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2007-11-02 12:02:16 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2007-11-02 12:02:16 +0000 |
commit | 557a7440b31464176de4baf82c03514e4bb9ef69 (patch) | |
tree | 0b2f7ef7c115d2f25df2a6f1508ce312c0d94a41 /tools | |
parent | INTEGRATION: CWS os2port02 (1.25.32); FILE MERGED (diff) | |
download | core-557a7440b31464176de4baf82c03514e4bb9ef69.tar.gz core-557a7440b31464176de4baf82c03514e4bb9ef69.zip |
INTEGRATION: CWS os2port02 (1.5.32); FILE MERGED
2007/09/30 12:08:51 ydario 1.5.32.1: Issue number: i82034
Submitted by: ydario
Reviewed by: ydario
Commit of changes for OS/2 CWS source code integration.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/fsys/fstat.cxx | 88 |
1 files changed, 84 insertions, 4 deletions
diff --git a/tools/source/fsys/fstat.cxx b/tools/source/fsys/fstat.cxx index baded08c600a..22396dcec9df 100644 --- a/tools/source/fsys/fstat.cxx +++ b/tools/source/fsys/fstat.cxx @@ -4,9 +4,9 @@ * * $RCSfile: fstat.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: hr $ $Date: 2007-06-27 22:11:00 $ + * last change: $Author: hr $ $Date: 2007-11-02 13:02:16 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -170,7 +170,7 @@ BOOL FileStat::IsKind( DirEntryKind nKind ) const BOOL FileStat::HasReadOnlyFlag() { -#if defined WNT || defined UNX +#if defined WNT || defined UNX || defined OS2 return TRUE; #else return FALSE; @@ -194,6 +194,16 @@ BOOL FileStat::GetReadOnlyFlag( const DirEntry &rEntry ) DWORD nRes = GetFileAttributes( (LPCTSTR) aFPath.GetBuffer() ); return ULONG_MAX != nRes && ( FILE_ATTRIBUTE_READONLY & nRes ) == FILE_ATTRIBUTE_READONLY; +#elif defined OS2 + FILESTATUS3 aFileStat; + APIRET nRet = DosQueryPathInfo( (PSZ)aFPath.GetBuffer(), 1, &aFileStat, sizeof(aFileStat) ); + switch ( nRet ) + { + case NO_ERROR: + return FILE_READONLY == ( aFileStat.attrFile & FILE_READONLY ); + default: + return FALSE; + } #elif defined UNX /* could we stat the object? */ struct stat aBuf; @@ -227,6 +237,26 @@ ULONG FileStat::SetReadOnlyFlag( const DirEntry &rEntry, BOOL bRO ) ( nRes & ~FILE_ATTRIBUTE_READONLY ) | ( bRO ? FILE_ATTRIBUTE_READONLY : 0 ) ); return ( ULONG_MAX == nRes ) ? ERRCODE_IO_UNKNOWN : 0; +#elif defined OS2 + FILESTATUS3 aFileStat; + APIRET nRet = DosQueryPathInfo( (PSZ)aFPath.GetBuffer(), 1, &aFileStat, sizeof(aFileStat) ); + if ( !nRet ) + { + aFileStat.attrFile = ( aFileStat.attrFile & ~FILE_READONLY ) | + ( bRO ? FILE_READONLY : 0 ); + nRet = DosSetPathInfo( (PSZ)aFPath.GetBuffer(), 1, &aFileStat, sizeof(aFileStat), 0 ); + } + switch ( nRet ) + { + case NO_ERROR: + return ERRCODE_NONE; + + case ERROR_SHARING_VIOLATION: + return ERRCODE_IO_LOCKVIOLATION; + + default: + return ERRCODE_IO_NOTEXISTS; + } #elif defined UNX /* first, stat the object to get permissions */ struct stat aBuf; @@ -269,7 +299,7 @@ ULONG FileStat::SetReadOnlyFlag( const DirEntry &rEntry, BOOL bRO ) |* Letzte Aenderung |* *************************************************************************/ -#if defined WNT +#if defined WNT || defined OS2 void FileStat::SetDateTime( const String& rFileName, const DateTime& rNewDateTime ) @@ -279,6 +309,7 @@ void FileStat::SetDateTime( const String& rFileName, Date aNewDate = rNewDateTime; Time aNewTime = rNewDateTime; +#if defined WNT TIME_ZONE_INFORMATION aTZI; DWORD dwTZI = GetTimeZoneInformation( &aTZI ); @@ -343,5 +374,54 @@ void FileStat::SetDateTime( const String& rFileName, SetFileTime( hFile, &aFileTime, &aFileTime, &aFileTime ); CloseHandle( hFile ); } +#elif defined OS2 + + // open file + ULONG nAction = FILE_EXISTED; + HFILE hFile = 0; + ULONG nFlags = OPEN_FLAGS_WRITE_THROUGH | + OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NO_CACHE | + OPEN_FLAGS_RANDOM | OPEN_FLAGS_NOINHERIT | + OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE; + + APIRET nRet = DosOpen((PSZ)aFileName.GetBuffer(), &hFile, (PULONG)&nAction, + 0/*size*/, FILE_NORMAL, + OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS, + nFlags, 0/*ea*/); + + if ( nRet == 0 ) + { + FILESTATUS3 FileInfoBuffer; + + nRet = DosQueryFileInfo( + hFile, 1, &FileInfoBuffer, sizeof(FileInfoBuffer)); + + if ( nRet == 0 ) + { + FDATE aNewDate; + FTIME aNewTime; + + // create date and time words + aNewDate.day = rNewDateTime.GetDay(); + aNewDate.month = rNewDateTime.GetMonth(); + aNewDate.year = rNewDateTime.GetYear() - 1980; + aNewTime.twosecs = rNewDateTime.GetSec() / 2; + aNewTime.minutes = rNewDateTime.GetMin(); + aNewTime.hours = rNewDateTime.GetHour(); + + // set file date and time + FileInfoBuffer.fdateCreation = aNewDate; + FileInfoBuffer.ftimeCreation = aNewTime; + FileInfoBuffer.fdateLastAccess = aNewDate; + FileInfoBuffer.ftimeLastAccess = aNewTime; + FileInfoBuffer.fdateLastWrite = aNewDate; + FileInfoBuffer.ftimeLastWrite = aNewTime; + + DosSetFileInfo(hFile, 1, &FileInfoBuffer, sizeof(FileInfoBuffer)); + } + DosClose(hFile); + } +#endif + } #endif |