summaryrefslogtreecommitdiffstats
path: root/generic/tclFileName.c
diff options
context:
space:
mode:
authordkf <dkf@noemail.net>2008-09-27 19:47:24 (GMT)
committerdkf <dkf@noemail.net>2008-09-27 19:47:24 (GMT)
commit6496c0c60e126d59c1664b0703a804d606970c75 (patch)
tree373293868711b69f211b994cbbe5ba95905f9623 /generic/tclFileName.c
parent8f1aaf6a08f03316917a40b62d4b47c918cf913a (diff)
downloadtcl-6496c0c60e126d59c1664b0703a804d606970c75.zip
tcl-6496c0c60e126d59c1664b0703a804d606970c75.tar.gz
tcl-6496c0c60e126d59c1664b0703a804d606970c75.tar.bz2
Fix [Bug 2130726].
FossilOrigin-Name: d18c55b8a232aa4e1907c162303b4c42eea7ba15
Diffstat (limited to 'generic/tclFileName.c')
-rw-r--r--generic/tclFileName.c25
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
}
/*