xref: /trunk/main/tools/source/fsys/unx.hxx (revision 8b851043)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _unx_hxx
25 #define _unx_hxx
26 
27 #include <string.h>
28 #include <sys/types.h>
29 #include <sys/stat.h>
30 #include <sys/param.h>
31 #include <dirent.h>
32 #include <unistd.h>
33 /* #include <sysent.h> */
34 
35 #define FSYS_UNIX TRUE
36 #define DRIVE_EXISTS(c) ( TRUE )
37 
38 #define _mkdir(p)       mkdir(p, 0777)
39 #define _rmdir          rmdir
40 #define _chdir          chdir
41 #define _unlink         unlink
42 #define _getcwd         getcwd
43 #define _access         access
44 
45 #ifdef SYSV3
46 #define DEFSTYLE        FSYS_STYLE_SYSV
47 #else
48 #define DEFSTYLE        FSYS_STYLE_BSD
49 #endif
50 
51 #define CMP_LOWER(s) 	(s)
52 #define TEMPNAME()      tmpnam(0)
53 #define LOWER(aString)  (aString.Lower())
54 
55 #include <time.h>
56 #include <tools/datetime.hxx>
57 
Unx2Time(time_t nTime)58 inline Time Unx2Time( time_t nTime )
59 {
60 	tm atm;
61     tm *pTime;
62     pTime = localtime_r( &nTime, &atm );
63     return Time( pTime->tm_hour,
64                  pTime->tm_min,
65                  pTime->tm_sec );
66 }
67 
Unx2Date(time_t nDate)68 inline Date Unx2Date( time_t nDate )
69 {
70 	tm atm;
71     tm *pTime;
72     pTime = localtime_r( &nDate, &atm );
73     return Date( pTime->tm_mday,
74                  pTime->tm_mon + 1,
75                  pTime->tm_year + 1900 );
76 }
77 
Unx2DateAndTime(time_t nDate,Time & rTime,Date & rDate)78 inline void Unx2DateAndTime( time_t nDate, Time& rTime, Date& rDate )
79 {
80 	tm atm;
81     tm *pTime;
82     pTime = localtime_r( &nDate, &atm );
83 	rTime = Time( pTime->tm_hour, pTime->tm_min, pTime->tm_sec );
84 	rDate = Date( pTime->tm_mday, pTime->tm_mon + 1, pTime->tm_year + 1900 );
85 }
86 
87 const char* TempDirImpl( char *pBuf );
88 
89 #define FSysFailOnErrorImpl()
90 
91 #endif
92