2 * See the file LICENSE for redistribution information.
4 * Copyright (c) 1997, 1998
5 * Sleepycat Software. All rights reserved.
11 static const char sccsid
[] = "@(#)os_stat.c 10.15 (Sleepycat) 4/27/98";
14 #ifndef NO_SYSTEM_INCLUDES
15 #include <sys/types.h>
25 * Return if the file exists.
27 * PUBLIC: int __os_exists __P((const char *, int *));
30 __os_exists(path
, isdirp
)
36 if (stat(path
, &sb
) != 0)
39 #if !defined(S_ISDIR) || defined(STAT_MACROS_BROKEN)
40 #if defined(_WIN32) || defined(WIN16)
41 #define S_ISDIR(m) (_S_IFDIR & (m))
43 #define S_ISDIR(m) (((m) & 0170000) == 0040000)
47 *isdirp
= S_ISDIR(sb
.st_mode
);
54 * Return file size and I/O size; abstracted to make it easier
57 * PUBLIC: int __os_ioinfo
58 * PUBLIC: __P((const char *, int, u_int32_t *, u_int32_t *, u_int32_t *));
61 __os_ioinfo(path
, fd
, mbytesp
, bytesp
, iosizep
)
64 u_int32_t
*mbytesp
, *bytesp
, *iosizep
;
68 COMPQUIET(path
, NULL
);
70 if (fstat(fd
, &sb
) == -1)
73 /* Return the size of the file. */
75 *mbytesp
= sb
.st_size
/ MEGABYTE
;
77 *bytesp
= sb
.st_size
% MEGABYTE
;
80 * Return the underlying filesystem blocksize, if available.
83 * Check for a 0 size -- HP's MPE architecture has st_blksize,
86 #ifdef HAVE_ST_BLKSIZE
87 if (iosizep
!= NULL
&& (*iosizep
= sb
.st_blksize
) == 0)
88 *iosizep
= DB_DEF_IOSIZE
;
91 *iosizep
= DB_DEF_IOSIZE
;