diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2008-09-27 19:47:24 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2008-09-27 19:47:24 (GMT) |
commit | 8d3e26a08c2d3528276032ef2b4f40949bd3d08d (patch) | |
tree | 373293868711b69f211b994cbbe5ba95905f9623 /generic/tclFileName.c | |
parent | 415263df239b3d23328d8af5672477b6d5d7c77c (diff) | |
download | tcl-8d3e26a08c2d3528276032ef2b4f40949bd3d08d.zip tcl-8d3e26a08c2d3528276032ef2b4f40949bd3d08d.tar.gz tcl-8d3e26a08c2d3528276032ef2b4f40949bd3d08d.tar.bz2 |
Fix [Bug 2130726].
Diffstat (limited to 'generic/tclFileName.c')
-rw-r--r-- | generic/tclFileName.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/generic/tclFileName.c b/generic/tclFileName.c index 00c7067..9ff6c07 100644 --- a/generic/tclFileName.c +++ b/generic/tclFileName.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclFileName.c,v 1.91 2008/09/24 09:41:20 dkf Exp $ + * RCS: @(#) $Id: tclFileName.c,v 1.92 2008/09/27 19:47:29 dkf Exp $ */ #include "tclInt.h" @@ -39,6 +39,16 @@ static Tcl_Obj * SplitUnixPath(const char *path); static int DoGlob(Tcl_Interp *interp, Tcl_Obj *resultPtr, const char *separators, Tcl_Obj *pathPtr, int flags, char *pattern, Tcl_GlobTypeData *types); + +/* + * When there is no support for getting the block size of a file in a stat() + * call, use this as a guess. Allow it to be overridden in the platform- + * specific files. + */ + +#if (!defined(HAVE_ST_BLOCKS) && !defined(GUESSED_BLOCK_SIZE)) +#define GUESSED_BLOCK_SIZE 1024 +#endif /* *---------------------------------------------------------------------- @@ -2625,14 +2635,27 @@ Tcl_WideUInt Tcl_GetBlocksFromStat( const Tcl_StatBuf *statPtr) { +#ifdef HAVE_ST_BLOCKS return (Tcl_WideUInt) statPtr->st_blocks; +#else + return ((Tcl_WideUInt) statPtr->st_size + + (GUESSED_BLOCK_SIZE-1)) / GUESSED_BLOCK_SIZE; +#endif } unsigned Tcl_GetBlockSizeFromStat( const Tcl_StatBuf *statPtr) { +#ifdef HAVE_ST_BLOCKS return (unsigned) statPtr->st_blksize; +#else + /* + * Not a great guess, but will do... + */ + + return GUESSED_BLOCK_SIZE; +#endif } /* |