diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclFCmd.c | 30 | ||||
-rw-r--r-- | generic/tclInt.decls | 25 | ||||
-rw-r--r-- | generic/tclIntPlatDecls.h | 46 | ||||
-rw-r--r-- | generic/tclStubInit.c | 8 |
4 files changed, 95 insertions, 14 deletions
diff --git a/generic/tclFCmd.c b/generic/tclFCmd.c index 50bea95..0d1cc76 100644 --- a/generic/tclFCmd.c +++ b/generic/tclFCmd.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclFCmd.c,v 1.20 2002/08/08 10:41:22 hobbs Exp $ + * RCS: @(#) $Id: tclFCmd.c,v 1.21 2003/05/14 19:21:22 das Exp $ */ #include "tclInt.h" @@ -918,21 +918,29 @@ TclFileAttrsCmd(interp, objc, objv) * Get all attributes. */ - int index; + int index, res = TCL_OK, nbAtts = 0; Tcl_Obj *listPtr; listPtr = Tcl_NewListObj(0, NULL); for (index = 0; attributeStrings[index] != NULL; index++) { - Tcl_Obj *objPtr = Tcl_NewStringObj(attributeStrings[index], -1); - Tcl_ListObjAppendElement(interp, listPtr, objPtr); - /* We now forget about objPtr, it is in the list */ - objPtr = NULL; - if (Tcl_FSFileAttrsGet(interp, index, filePtr, - &objPtr) != TCL_OK) { - Tcl_DecrRefCount(listPtr); - goto end; + Tcl_Obj *objPtrAttr; + + if (res != TCL_OK) { + /* Clear the error from the last iteration */ + Tcl_ResetResult(interp); } - Tcl_ListObjAppendElement(interp, listPtr, objPtr); + res = Tcl_FSFileAttrsGet(interp, index, filePtr, &objPtrAttr); + if (res == TCL_OK) { + Tcl_Obj *objPtr = Tcl_NewStringObj(attributeStrings[index], -1); + Tcl_ListObjAppendElement(interp, listPtr, objPtr); + Tcl_ListObjAppendElement(interp, listPtr, objPtrAttr); + nbAtts++; + } + } + if (index > 0 && nbAtts == 0) { + /* Error: no valid attributes found */ + Tcl_DecrRefCount(listPtr); + goto end; } Tcl_SetObjResult(interp, listPtr); } else if (objc == 1) { diff --git a/generic/tclInt.decls b/generic/tclInt.decls index d68aa29..1a03642 100644 --- a/generic/tclInt.decls +++ b/generic/tclInt.decls @@ -12,7 +12,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: tclInt.decls,v 1.60 2003/04/28 12:34:27 dkf Exp $ +# RCS: @(#) $Id: tclInt.decls,v 1.61 2003/05/14 19:21:22 das Exp $ library tcl @@ -993,3 +993,26 @@ declare 12 unix { declare 13 unix { char *TclpInetNtoa(struct in_addr addr) } + +# Added in 8.5: + +declare 14 unix { + int TclUnixCopyFile (CONST char *src, CONST char *dst, + CONST Tcl_StatBuf *statBufPtr, int dontCopyAtts) +} + +declare 15 macosx { + int TclMacOSXGetFileAttribute(Tcl_Interp *interp, int objIndex, + Tcl_Obj *fileName, Tcl_Obj **attributePtrPtr) +} + +declare 16 macosx { + int TclMacOSXSetFileAttribute(Tcl_Interp *interp, int objIndex, + Tcl_Obj *fileName, Tcl_Obj *attributePtr) +} + +declare 17 macosx { + int TclMacOSXCopyFileAttributes(CONST char *src, CONST char *dst, + CONST Tcl_StatBuf *statBufPtr) +} + diff --git a/generic/tclIntPlatDecls.h b/generic/tclIntPlatDecls.h index 09c1226..b9a9dc5 100644 --- a/generic/tclIntPlatDecls.h +++ b/generic/tclIntPlatDecls.h @@ -9,7 +9,7 @@ * Copyright (c) 1998-1999 by Scriptics Corporation. * All rights reserved. * - * RCS: @(#) $Id: tclIntPlatDecls.h,v 1.19 2002/12/06 23:22:59 hobbs Exp $ + * RCS: @(#) $Id: tclIntPlatDecls.h,v 1.20 2003/05/14 19:21:22 das Exp $ */ #ifndef _TCLINTPLATDECLS @@ -67,6 +67,11 @@ EXTERN struct tm * TclpLocaltime _ANSI_ARGS_((time_t * clock)); EXTERN struct tm * TclpGmtime _ANSI_ARGS_((time_t * clock)); /* 13 */ EXTERN char * TclpInetNtoa _ANSI_ARGS_((struct in_addr addr)); +/* 14 */ +EXTERN int TclUnixCopyFile _ANSI_ARGS_((CONST char * src, + CONST char * dst, + CONST Tcl_StatBuf * statBufPtr, + int dontCopyAtts)); #endif /* UNIX */ #ifdef __WIN32__ /* 0 */ @@ -212,6 +217,21 @@ EXTERN int TclMacChmod _ANSI_ARGS_((CONST char * path, int mode)); EXTERN int FSpLLocationFromPath _ANSI_ARGS_((int length, CONST char * path, FSSpecPtr theSpec)); #endif /* MAC_TCL */ +#ifdef MAC_OSX_TCL +/* 15 */ +EXTERN int TclMacOSXGetFileAttribute _ANSI_ARGS_(( + Tcl_Interp * interp, int objIndex, + Tcl_Obj * fileName, + Tcl_Obj ** attributePtrPtr)); +/* 16 */ +EXTERN int TclMacOSXSetFileAttribute _ANSI_ARGS_(( + Tcl_Interp * interp, int objIndex, + Tcl_Obj * fileName, Tcl_Obj * attributePtr)); +/* 17 */ +EXTERN int TclMacOSXCopyFileAttributes _ANSI_ARGS_(( + CONST char * src, CONST char * dst, + CONST Tcl_StatBuf * statBufPtr)); +#endif /* MAC_OSX_TCL */ typedef struct TclIntPlatStubs { int magic; @@ -232,6 +252,7 @@ typedef struct TclIntPlatStubs { struct tm * (*tclpLocaltime) _ANSI_ARGS_((time_t * clock)); /* 11 */ struct tm * (*tclpGmtime) _ANSI_ARGS_((time_t * clock)); /* 12 */ char * (*tclpInetNtoa) _ANSI_ARGS_((struct in_addr addr)); /* 13 */ + int (*tclUnixCopyFile) _ANSI_ARGS_((CONST char * src, CONST char * dst, CONST Tcl_StatBuf * statBufPtr, int dontCopyAtts)); /* 14 */ #endif /* UNIX */ #ifdef __WIN32__ void (*tclWinConvertError) _ANSI_ARGS_((DWORD errCode)); /* 0 */ @@ -293,6 +314,11 @@ typedef struct TclIntPlatStubs { int (*tclMacChmod) _ANSI_ARGS_((CONST char * path, int mode)); /* 25 */ int (*fSpLLocationFromPath) _ANSI_ARGS_((int length, CONST char * path, FSSpecPtr theSpec)); /* 26 */ #endif /* MAC_TCL */ +#ifdef MAC_OSX_TCL + int (*tclMacOSXGetFileAttribute) _ANSI_ARGS_((Tcl_Interp * interp, int objIndex, Tcl_Obj * fileName, Tcl_Obj ** attributePtrPtr)); /* 15 */ + int (*tclMacOSXSetFileAttribute) _ANSI_ARGS_((Tcl_Interp * interp, int objIndex, Tcl_Obj * fileName, Tcl_Obj * attributePtr)); /* 16 */ + int (*tclMacOSXCopyFileAttributes) _ANSI_ARGS_((CONST char * src, CONST char * dst, CONST Tcl_StatBuf * statBufPtr)); /* 17 */ +#endif /* MAC_OSX_TCL */ } TclIntPlatStubs; #ifdef __cplusplus @@ -363,6 +389,10 @@ extern TclIntPlatStubs *tclIntPlatStubsPtr; #define TclpInetNtoa \ (tclIntPlatStubsPtr->tclpInetNtoa) /* 13 */ #endif +#ifndef TclUnixCopyFile +#define TclUnixCopyFile \ + (tclIntPlatStubsPtr->tclUnixCopyFile) /* 14 */ +#endif #endif /* UNIX */ #ifdef __WIN32__ #ifndef TclWinConvertError @@ -577,6 +607,20 @@ extern TclIntPlatStubs *tclIntPlatStubsPtr; (tclIntPlatStubsPtr->fSpLLocationFromPath) /* 26 */ #endif #endif /* MAC_TCL */ +#ifdef MAC_OSX_TCL +#ifndef TclMacOSXGetFileAttribute +#define TclMacOSXGetFileAttribute \ + (tclIntPlatStubsPtr->tclMacOSXGetFileAttribute) /* 15 */ +#endif +#ifndef TclMacOSXSetFileAttribute +#define TclMacOSXSetFileAttribute \ + (tclIntPlatStubsPtr->tclMacOSXSetFileAttribute) /* 16 */ +#endif +#ifndef TclMacOSXCopyFileAttributes +#define TclMacOSXCopyFileAttributes \ + (tclIntPlatStubsPtr->tclMacOSXCopyFileAttributes) /* 17 */ +#endif +#endif /* MAC_OSX_TCL */ #endif /* defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) */ diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 60fff39..6bd10ef 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclStubInit.c,v 1.83 2003/05/13 08:40:31 das Exp $ + * RCS: @(#) $Id: tclStubInit.c,v 1.84 2003/05/14 19:21:23 das Exp $ */ #include "tclInt.h" @@ -289,6 +289,7 @@ TclIntPlatStubs tclIntPlatStubs = { TclpLocaltime, /* 11 */ TclpGmtime, /* 12 */ TclpInetNtoa, /* 13 */ + TclUnixCopyFile, /* 14 */ #endif /* UNIX */ #ifdef __WIN32__ TclWinConvertError, /* 0 */ @@ -350,6 +351,11 @@ TclIntPlatStubs tclIntPlatStubs = { TclMacChmod, /* 25 */ FSpLLocationFromPath, /* 26 */ #endif /* MAC_TCL */ +#ifdef MAC_OSX_TCL + TclMacOSXGetFileAttribute, /* 15 */ + TclMacOSXSetFileAttribute, /* 16 */ + TclMacOSXCopyFileAttributes, /* 17 */ +#endif /* MAC_OSX_TCL */ }; TclPlatStubs tclPlatStubs = { |