1*89b56da7SAndrew Rist /**************************************************************
2*89b56da7SAndrew Rist *
3*89b56da7SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*89b56da7SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*89b56da7SAndrew Rist * distributed with this work for additional information
6*89b56da7SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*89b56da7SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*89b56da7SAndrew Rist * "License"); you may not use this file except in compliance
9*89b56da7SAndrew Rist * with the License. You may obtain a copy of the License at
10*89b56da7SAndrew Rist *
11*89b56da7SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*89b56da7SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*89b56da7SAndrew Rist * software distributed under the License is distributed on an
15*89b56da7SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*89b56da7SAndrew Rist * KIND, either express or implied. See the License for the
17*89b56da7SAndrew Rist * specific language governing permissions and limitations
18*89b56da7SAndrew Rist * under the License.
19*89b56da7SAndrew Rist *
20*89b56da7SAndrew Rist *************************************************************/
21*89b56da7SAndrew Rist
22*89b56da7SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_tools.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #ifdef UNX
28cdf0e10cSrcweir #include <errno.h>
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include <limits.h>
32cdf0e10cSrcweir #include <string.h>
33cdf0e10cSrcweir
34cdf0e10cSrcweir #include "comdep.hxx"
35cdf0e10cSrcweir #include <tools/fsys.hxx>
36cdf0e10cSrcweir
37cdf0e10cSrcweir /*************************************************************************
38cdf0e10cSrcweir |*
39cdf0e10cSrcweir |* FileStat::FileStat()
40cdf0e10cSrcweir |*
41cdf0e10cSrcweir |* Beschreibung FSYS.SDW
42cdf0e10cSrcweir |* Ersterstellung MI 11.06.91
43cdf0e10cSrcweir |* Letzte Aenderung MI 11.06.91
44cdf0e10cSrcweir |*
45cdf0e10cSrcweir *************************************************************************/
46cdf0e10cSrcweir
FileStat()47cdf0e10cSrcweir FileStat::FileStat()
48cdf0e10cSrcweir : // don't use Default-Ctors!
49cdf0e10cSrcweir aDateCreated( sal_uIntPtr(0) ),
50cdf0e10cSrcweir aTimeCreated( sal_uIntPtr(0) ),
51cdf0e10cSrcweir aDateModified( sal_uIntPtr(0) ),
52cdf0e10cSrcweir aTimeModified( sal_uIntPtr(0) ),
53cdf0e10cSrcweir aDateAccessed( sal_uIntPtr(0) ),
54cdf0e10cSrcweir aTimeAccessed( sal_uIntPtr(0) )
55cdf0e10cSrcweir {
56cdf0e10cSrcweir nSize = 0;
57cdf0e10cSrcweir nKindFlags = FSYS_KIND_UNKNOWN;
58cdf0e10cSrcweir nError = FSYS_ERR_OK;
59cdf0e10cSrcweir }
60cdf0e10cSrcweir
61cdf0e10cSrcweir /*************************************************************************
62cdf0e10cSrcweir |*
63cdf0e10cSrcweir |* FileStat::FileStat()
64cdf0e10cSrcweir |*
65cdf0e10cSrcweir |* Beschreibung FSYS.SDW
66cdf0e10cSrcweir |* Ersterstellung MI 11.06.91
67cdf0e10cSrcweir |* Letzte Aenderung MI 11.06.91
68cdf0e10cSrcweir |*
69cdf0e10cSrcweir *************************************************************************/
70cdf0e10cSrcweir
FileStat(const DirEntry & rDirEntry,FSysAccess nAccess)71cdf0e10cSrcweir FileStat::FileStat( const DirEntry& rDirEntry, FSysAccess nAccess )
72cdf0e10cSrcweir : // don't use Default-Ctors!
73cdf0e10cSrcweir aDateCreated( sal_uIntPtr(0) ),
74cdf0e10cSrcweir aTimeCreated( sal_uIntPtr(0) ),
75cdf0e10cSrcweir aDateModified( sal_uIntPtr(0) ),
76cdf0e10cSrcweir aTimeModified( sal_uIntPtr(0) ),
77cdf0e10cSrcweir aDateAccessed( sal_uIntPtr(0) ),
78cdf0e10cSrcweir aTimeAccessed( sal_uIntPtr(0) )
79cdf0e10cSrcweir {
80cdf0e10cSrcweir sal_Bool bCached = FSYS_ACCESS_CACHED == (nAccess & FSYS_ACCESS_CACHED);
81cdf0e10cSrcweir sal_Bool bFloppy = FSYS_ACCESS_FLOPPY == (nAccess & FSYS_ACCESS_FLOPPY);
82cdf0e10cSrcweir
83cdf0e10cSrcweir #ifdef FEAT_FSYS_DOUBLESPEED
84cdf0e10cSrcweir const FileStat *pStatFromDir = bCached ? rDirEntry.ImpGetStat() : 0;
85cdf0e10cSrcweir if ( pStatFromDir )
86cdf0e10cSrcweir {
87cdf0e10cSrcweir nError = pStatFromDir->nError;
88cdf0e10cSrcweir nKindFlags = pStatFromDir->nKindFlags;
89cdf0e10cSrcweir nSize = pStatFromDir->nSize;
90cdf0e10cSrcweir aCreator = pStatFromDir->aCreator;
91cdf0e10cSrcweir aType = pStatFromDir->aType;
92cdf0e10cSrcweir aDateCreated = pStatFromDir->aDateCreated;
93cdf0e10cSrcweir aTimeCreated = pStatFromDir->aTimeCreated;
94cdf0e10cSrcweir aDateModified = pStatFromDir->aDateModified;
95cdf0e10cSrcweir aTimeModified = pStatFromDir->aTimeModified;
96cdf0e10cSrcweir aDateAccessed = pStatFromDir->aDateAccessed;
97cdf0e10cSrcweir aTimeAccessed = pStatFromDir->aTimeAccessed;
98cdf0e10cSrcweir }
99cdf0e10cSrcweir else
100cdf0e10cSrcweir #endif
101cdf0e10cSrcweir Update( rDirEntry, bFloppy );
102cdf0e10cSrcweir }
103cdf0e10cSrcweir
104cdf0e10cSrcweir /*************************************************************************
105cdf0e10cSrcweir |*
106cdf0e10cSrcweir |* FileStat::IsYounger()
107cdf0e10cSrcweir |*
108cdf0e10cSrcweir |* Beschreibung FSYS.SDW
109cdf0e10cSrcweir |* Ersterstellung MA 11.11.91
110cdf0e10cSrcweir |* Letzte Aenderung MA 11.11.91
111cdf0e10cSrcweir |*
112cdf0e10cSrcweir *************************************************************************/
113cdf0e10cSrcweir
114cdf0e10cSrcweir // sal_True wenn die Instanz j"unger als rIsOlder ist.
115cdf0e10cSrcweir // sal_False wenn die Instanz "alter oder gleich alt wie rIsOlder ist.
116cdf0e10cSrcweir
IsYounger(const FileStat & rIsOlder) const117cdf0e10cSrcweir sal_Bool FileStat::IsYounger( const FileStat& rIsOlder ) const
118cdf0e10cSrcweir {
119cdf0e10cSrcweir if ( aDateModified > rIsOlder.aDateModified )
120cdf0e10cSrcweir return sal_True;
121cdf0e10cSrcweir if ( ( aDateModified == rIsOlder.aDateModified ) &&
122cdf0e10cSrcweir ( aTimeModified > rIsOlder.aTimeModified ) )
123cdf0e10cSrcweir return sal_True;
124cdf0e10cSrcweir
125cdf0e10cSrcweir return sal_False;
126cdf0e10cSrcweir }
127cdf0e10cSrcweir
128cdf0e10cSrcweir /*************************************************************************
129cdf0e10cSrcweir |*
130cdf0e10cSrcweir |* FileStat::IsKind()
131cdf0e10cSrcweir |*
132cdf0e10cSrcweir |* Ersterstellung MA 11.11.91 (?)
133cdf0e10cSrcweir |* Letzte Aenderung KH 16.01.95
134cdf0e10cSrcweir |*
135cdf0e10cSrcweir *************************************************************************/
136cdf0e10cSrcweir
IsKind(DirEntryKind nKind) const137cdf0e10cSrcweir sal_Bool FileStat::IsKind( DirEntryKind nKind ) const
138cdf0e10cSrcweir {
139cdf0e10cSrcweir sal_Bool bRet = ( ( nKind == FSYS_KIND_UNKNOWN ) &&
140cdf0e10cSrcweir ( nKindFlags == FSYS_KIND_UNKNOWN ) ) ||
141cdf0e10cSrcweir ( ( nKindFlags & nKind ) == nKind );
142cdf0e10cSrcweir return bRet;
143cdf0e10cSrcweir }
144cdf0e10cSrcweir
145cdf0e10cSrcweir /*************************************************************************
146cdf0e10cSrcweir |*
147cdf0e10cSrcweir |* FileStat::HasReadOnlyFlag()
148cdf0e10cSrcweir |*
149cdf0e10cSrcweir |* Ersterstellung MI 06.03.97
150cdf0e10cSrcweir |* Letzte Aenderung UT 01.07.98
151cdf0e10cSrcweir |*
152cdf0e10cSrcweir *************************************************************************/
153cdf0e10cSrcweir
HasReadOnlyFlag()154cdf0e10cSrcweir sal_Bool FileStat::HasReadOnlyFlag()
155cdf0e10cSrcweir {
156cdf0e10cSrcweir #if defined WNT || defined UNX || defined OS2
157cdf0e10cSrcweir return sal_True;
158cdf0e10cSrcweir #else
159cdf0e10cSrcweir return sal_False;
160cdf0e10cSrcweir #endif
161cdf0e10cSrcweir }
162cdf0e10cSrcweir
163cdf0e10cSrcweir /*************************************************************************
164cdf0e10cSrcweir |*
165cdf0e10cSrcweir |* FileStat::GetReadOnlyFlag()
166cdf0e10cSrcweir |*
167cdf0e10cSrcweir |* Ersterstellung MI 06.03.97
168cdf0e10cSrcweir |* Letzte Aenderung UT 02.07.98
169cdf0e10cSrcweir |*
170cdf0e10cSrcweir *************************************************************************/
171cdf0e10cSrcweir
GetReadOnlyFlag(const DirEntry & rEntry)172cdf0e10cSrcweir sal_Bool FileStat::GetReadOnlyFlag( const DirEntry &rEntry )
173cdf0e10cSrcweir {
174cdf0e10cSrcweir
175cdf0e10cSrcweir ByteString aFPath(rEntry.GetFull(), osl_getThreadTextEncoding());
176cdf0e10cSrcweir #if defined WNT
177cdf0e10cSrcweir DWORD nRes = GetFileAttributes( (LPCTSTR) aFPath.GetBuffer() );
178cdf0e10cSrcweir return ULONG_MAX != nRes &&
179cdf0e10cSrcweir ( FILE_ATTRIBUTE_READONLY & nRes ) == FILE_ATTRIBUTE_READONLY;
180cdf0e10cSrcweir #elif defined OS2
181cdf0e10cSrcweir FILESTATUS3 aFileStat;
182cdf0e10cSrcweir APIRET nRet = DosQueryPathInfo( (PSZ)aFPath.GetBuffer(), 1, &aFileStat, sizeof(aFileStat) );
183cdf0e10cSrcweir switch ( nRet )
184cdf0e10cSrcweir {
185cdf0e10cSrcweir case NO_ERROR:
186cdf0e10cSrcweir return FILE_READONLY == ( aFileStat.attrFile & FILE_READONLY );
187cdf0e10cSrcweir default:
188cdf0e10cSrcweir return sal_False;
189cdf0e10cSrcweir }
190cdf0e10cSrcweir #elif defined UNX
191cdf0e10cSrcweir /* could we stat the object? */
192cdf0e10cSrcweir struct stat aBuf;
193cdf0e10cSrcweir if (stat(aFPath.GetBuffer(), &aBuf))
194cdf0e10cSrcweir return sal_False;
195cdf0e10cSrcweir /* jupp, is writable for user? */
196cdf0e10cSrcweir return((aBuf.st_mode & S_IWUSR) != S_IWUSR);
197cdf0e10cSrcweir #else
198cdf0e10cSrcweir return sal_False;
199cdf0e10cSrcweir #endif
200cdf0e10cSrcweir }
201cdf0e10cSrcweir
202cdf0e10cSrcweir /*************************************************************************
203cdf0e10cSrcweir |*
204cdf0e10cSrcweir |* FileStat::SetReadOnlyFlag()
205cdf0e10cSrcweir |*
206cdf0e10cSrcweir |* Ersterstellung MI 06.03.97
207cdf0e10cSrcweir |* Letzte Aenderung UT 01.07.98
208cdf0e10cSrcweir |*
209cdf0e10cSrcweir *************************************************************************/
210cdf0e10cSrcweir
SetReadOnlyFlag(const DirEntry & rEntry,sal_Bool bRO)211cdf0e10cSrcweir sal_uIntPtr FileStat::SetReadOnlyFlag( const DirEntry &rEntry, sal_Bool bRO )
212cdf0e10cSrcweir {
213cdf0e10cSrcweir
214cdf0e10cSrcweir ByteString aFPath(rEntry.GetFull(), osl_getThreadTextEncoding());
215cdf0e10cSrcweir
216cdf0e10cSrcweir #if defined WNT
217cdf0e10cSrcweir DWORD nRes = GetFileAttributes( (LPCTSTR) aFPath.GetBuffer() );
218cdf0e10cSrcweir if ( ULONG_MAX != nRes )
219cdf0e10cSrcweir nRes = SetFileAttributes( (LPCTSTR) aFPath.GetBuffer(),
220cdf0e10cSrcweir ( nRes & ~FILE_ATTRIBUTE_READONLY ) |
221cdf0e10cSrcweir ( bRO ? FILE_ATTRIBUTE_READONLY : 0 ) );
222cdf0e10cSrcweir return ( ULONG_MAX == nRes ) ? ERRCODE_IO_UNKNOWN : 0;
223cdf0e10cSrcweir #elif defined OS2
224cdf0e10cSrcweir FILESTATUS3 aFileStat;
225cdf0e10cSrcweir APIRET nRet = DosQueryPathInfo( (PSZ)aFPath.GetBuffer(), 1, &aFileStat, sizeof(aFileStat) );
226cdf0e10cSrcweir if ( !nRet )
227cdf0e10cSrcweir {
228cdf0e10cSrcweir aFileStat.attrFile = ( aFileStat.attrFile & ~FILE_READONLY ) |
229cdf0e10cSrcweir ( bRO ? FILE_READONLY : 0 );
230cdf0e10cSrcweir nRet = DosSetPathInfo( (PSZ)aFPath.GetBuffer(), 1, &aFileStat, sizeof(aFileStat), 0 );
231cdf0e10cSrcweir }
232cdf0e10cSrcweir switch ( nRet )
233cdf0e10cSrcweir {
234cdf0e10cSrcweir case NO_ERROR:
235cdf0e10cSrcweir return ERRCODE_NONE;
236cdf0e10cSrcweir
237cdf0e10cSrcweir case ERROR_SHARING_VIOLATION:
238cdf0e10cSrcweir return ERRCODE_IO_LOCKVIOLATION;
239cdf0e10cSrcweir
240cdf0e10cSrcweir default:
241cdf0e10cSrcweir return ERRCODE_IO_NOTEXISTS;
242cdf0e10cSrcweir }
243cdf0e10cSrcweir #elif defined UNX
244cdf0e10cSrcweir /* first, stat the object to get permissions */
245cdf0e10cSrcweir struct stat aBuf;
246cdf0e10cSrcweir if (stat(aFPath.GetBuffer(), &aBuf))
247cdf0e10cSrcweir return ERRCODE_IO_NOTEXISTS;
248cdf0e10cSrcweir /* set or clear write bit for user */
249cdf0e10cSrcweir mode_t nMode;
250cdf0e10cSrcweir if (bRO)
251cdf0e10cSrcweir {
252cdf0e10cSrcweir nMode = aBuf.st_mode & ~S_IWUSR;
253cdf0e10cSrcweir nMode = aBuf.st_mode & ~S_IWGRP;
254cdf0e10cSrcweir nMode = aBuf.st_mode & ~S_IWOTH;
255cdf0e10cSrcweir }
256cdf0e10cSrcweir else
257cdf0e10cSrcweir nMode = aBuf.st_mode | S_IWUSR;
258cdf0e10cSrcweir /* change it on fs */
259cdf0e10cSrcweir if (chmod(aFPath.GetBuffer(), nMode))
260cdf0e10cSrcweir {
261cdf0e10cSrcweir switch (errno)
262cdf0e10cSrcweir {
263cdf0e10cSrcweir case EPERM :
264cdf0e10cSrcweir case EROFS :
265cdf0e10cSrcweir return ERRCODE_IO_ACCESSDENIED;
266cdf0e10cSrcweir default :
267cdf0e10cSrcweir return ERRCODE_IO_NOTEXISTS;
268cdf0e10cSrcweir }
269cdf0e10cSrcweir }
270cdf0e10cSrcweir else
271cdf0e10cSrcweir return ERRCODE_NONE;
272cdf0e10cSrcweir #else
273cdf0e10cSrcweir return ERRCODE_IO_NOTSUPPORTED;
274cdf0e10cSrcweir #endif
275cdf0e10cSrcweir }
276cdf0e10cSrcweir
277cdf0e10cSrcweir /*************************************************************************
278cdf0e10cSrcweir |*
279cdf0e10cSrcweir |* FileStat::SetDateTime
280cdf0e10cSrcweir |*
281cdf0e10cSrcweir |* Ersterstellung PB 27.06.97
282cdf0e10cSrcweir |* Letzte Aenderung
283cdf0e10cSrcweir |*
284cdf0e10cSrcweir *************************************************************************/
285cdf0e10cSrcweir #if defined WNT || defined OS2
286cdf0e10cSrcweir
SetDateTime(const String & rFileName,const DateTime & rNewDateTime)287cdf0e10cSrcweir void FileStat::SetDateTime( const String& rFileName,
288cdf0e10cSrcweir const DateTime& rNewDateTime )
289cdf0e10cSrcweir {
290cdf0e10cSrcweir ByteString aFileName(rFileName, osl_getThreadTextEncoding());
291cdf0e10cSrcweir
292cdf0e10cSrcweir Date aNewDate = rNewDateTime;
293cdf0e10cSrcweir Time aNewTime = rNewDateTime;
294cdf0e10cSrcweir
295cdf0e10cSrcweir #if defined WNT
296cdf0e10cSrcweir TIME_ZONE_INFORMATION aTZI;
297cdf0e10cSrcweir DWORD dwTZI = GetTimeZoneInformation( &aTZI );
298cdf0e10cSrcweir
299cdf0e10cSrcweir if ( dwTZI != (DWORD)-1 && dwTZI != TIME_ZONE_ID_UNKNOWN )
300cdf0e10cSrcweir {
301cdf0e10cSrcweir // 1. Korrektur der Zeitzone
302cdf0e10cSrcweir LONG nDiff = aTZI.Bias;
303cdf0e10cSrcweir Time aOldTime = aNewTime; // alte Zeit merken
304cdf0e10cSrcweir
305cdf0e10cSrcweir // 2. evt. Korrektur Sommer-/Winterzeit
306cdf0e10cSrcweir if ( dwTZI == TIME_ZONE_ID_DAYLIGHT )
307cdf0e10cSrcweir nDiff += aTZI.DaylightBias;
308cdf0e10cSrcweir
309cdf0e10cSrcweir Time aDiff( abs( nDiff / 60 /*Min -> Std*/ ), 0 );
310cdf0e10cSrcweir
311cdf0e10cSrcweir if ( nDiff > 0 )
312cdf0e10cSrcweir {
313cdf0e10cSrcweir aNewTime += aDiff; // Stundenkorrektur
314cdf0e10cSrcweir
315cdf0e10cSrcweir // bei "Uberlauf korrigieren
316cdf0e10cSrcweir if ( aNewTime >= Time( 24, 0 ) )
317cdf0e10cSrcweir aNewTime -= Time( 24, 0 );
318cdf0e10cSrcweir
319cdf0e10cSrcweir // Tages"uberlauf?
320cdf0e10cSrcweir if ( aOldTime == Time( 0, 0 ) || // 00:00 -> 01:00
321cdf0e10cSrcweir aNewTime < aOldTime ) // 23:00 -> 00:00 | 01:00 ...
322cdf0e10cSrcweir aNewDate++;
323cdf0e10cSrcweir }
324cdf0e10cSrcweir else if ( nDiff < 0 )
325cdf0e10cSrcweir {
326cdf0e10cSrcweir aNewTime -= aDiff; // Stundenkorrektur
327cdf0e10cSrcweir
328cdf0e10cSrcweir // negative Zeit (-1:00) korrigieren: 23:00
329cdf0e10cSrcweir if (aNewTime < Time( 0, 0 ) )
330cdf0e10cSrcweir aNewTime += Time( 24, 0 );
331cdf0e10cSrcweir
332cdf0e10cSrcweir // Tagesunterlauf ?
333cdf0e10cSrcweir if ( aOldTime == Time( 0, 0 ) || // 00:00 -> 23:00
334cdf0e10cSrcweir aNewTime > aOldTime ) // 01:00 -> 23:00 | 22:00 ...
335cdf0e10cSrcweir aNewDate--;
336cdf0e10cSrcweir }
337cdf0e10cSrcweir }
338cdf0e10cSrcweir
339cdf0e10cSrcweir
340cdf0e10cSrcweir SYSTEMTIME aTime;
341cdf0e10cSrcweir aTime.wYear = aNewDate.GetYear();
342cdf0e10cSrcweir aTime.wMonth = aNewDate.GetMonth();
343cdf0e10cSrcweir aTime.wDayOfWeek = 0;
344cdf0e10cSrcweir aTime.wDay = aNewDate.GetDay();
345cdf0e10cSrcweir aTime.wHour = aNewTime.GetHour();
346cdf0e10cSrcweir aTime.wMinute = aNewTime.GetMin();
347cdf0e10cSrcweir aTime.wSecond = aNewTime.GetSec();
348cdf0e10cSrcweir aTime.wMilliseconds = 0;
349cdf0e10cSrcweir FILETIME aFileTime;
350cdf0e10cSrcweir SystemTimeToFileTime( &aTime, &aFileTime );
351cdf0e10cSrcweir
352cdf0e10cSrcweir HANDLE hFile = CreateFile( aFileName.GetBuffer(), GENERIC_WRITE, 0, 0,
353cdf0e10cSrcweir OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 );
354cdf0e10cSrcweir
355cdf0e10cSrcweir if ( hFile != INVALID_HANDLE_VALUE )
356cdf0e10cSrcweir {
357cdf0e10cSrcweir SetFileTime( hFile, &aFileTime, &aFileTime, &aFileTime );
358cdf0e10cSrcweir CloseHandle( hFile );
359cdf0e10cSrcweir }
360cdf0e10cSrcweir #elif defined OS2
361cdf0e10cSrcweir
362cdf0e10cSrcweir // open file
363cdf0e10cSrcweir ULONG nAction = FILE_EXISTED;
364cdf0e10cSrcweir HFILE hFile = 0;
365cdf0e10cSrcweir ULONG nFlags = OPEN_FLAGS_WRITE_THROUGH |
366cdf0e10cSrcweir OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NO_CACHE |
367cdf0e10cSrcweir OPEN_FLAGS_RANDOM | OPEN_FLAGS_NOINHERIT |
368cdf0e10cSrcweir OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE;
369cdf0e10cSrcweir
370cdf0e10cSrcweir APIRET nRet = DosOpen((PSZ)aFileName.GetBuffer(), &hFile, (PULONG)&nAction,
371cdf0e10cSrcweir 0/*size*/, FILE_NORMAL,
372cdf0e10cSrcweir OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
373cdf0e10cSrcweir nFlags, 0/*ea*/);
374cdf0e10cSrcweir
375cdf0e10cSrcweir if ( nRet == 0 )
376cdf0e10cSrcweir {
377cdf0e10cSrcweir FILESTATUS3 FileInfoBuffer;
378cdf0e10cSrcweir
379cdf0e10cSrcweir nRet = DosQueryFileInfo(
380cdf0e10cSrcweir hFile, 1, &FileInfoBuffer, sizeof(FileInfoBuffer));
381cdf0e10cSrcweir
382cdf0e10cSrcweir if ( nRet == 0 )
383cdf0e10cSrcweir {
384cdf0e10cSrcweir FDATE aNewDate;
385cdf0e10cSrcweir FTIME aNewTime;
386cdf0e10cSrcweir
387cdf0e10cSrcweir // create date and time words
388cdf0e10cSrcweir aNewDate.day = rNewDateTime.GetDay();
389cdf0e10cSrcweir aNewDate.month = rNewDateTime.GetMonth();
390cdf0e10cSrcweir aNewDate.year = rNewDateTime.GetYear() - 1980;
391cdf0e10cSrcweir aNewTime.twosecs = rNewDateTime.GetSec() / 2;
392cdf0e10cSrcweir aNewTime.minutes = rNewDateTime.GetMin();
393cdf0e10cSrcweir aNewTime.hours = rNewDateTime.GetHour();
394cdf0e10cSrcweir
395cdf0e10cSrcweir // set file date and time
396cdf0e10cSrcweir FileInfoBuffer.fdateCreation = aNewDate;
397cdf0e10cSrcweir FileInfoBuffer.ftimeCreation = aNewTime;
398cdf0e10cSrcweir FileInfoBuffer.fdateLastAccess = aNewDate;
399cdf0e10cSrcweir FileInfoBuffer.ftimeLastAccess = aNewTime;
400cdf0e10cSrcweir FileInfoBuffer.fdateLastWrite = aNewDate;
401cdf0e10cSrcweir FileInfoBuffer.ftimeLastWrite = aNewTime;
402cdf0e10cSrcweir
403cdf0e10cSrcweir DosSetFileInfo(hFile, 1, &FileInfoBuffer, sizeof(FileInfoBuffer));
404cdf0e10cSrcweir }
405cdf0e10cSrcweir DosClose(hFile);
406cdf0e10cSrcweir }
407cdf0e10cSrcweir #endif
408cdf0e10cSrcweir
409cdf0e10cSrcweir }
410cdf0e10cSrcweir #endif
411