Diff
Not logged in

Differences From Artifact [91bdd6013b]:

To Artifact [52dbe8b14c]:


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 *
 * Copyright (c) 1991-1994 The Regents of the University of California.
 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclIOUtil.c,v 1.77.2.20 2004/12/02 18:48:14 vincentdarley Exp $
 */

#include "tclInt.h"
#include "tclPort.h"
#ifdef MAC_TCL
#include "tclMacInt.h"
#endif







|







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 *
 * Copyright (c) 1991-1994 The Regents of the University of California.
 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclIOUtil.c,v 1.77.2.21 2005/05/24 04:19:32 das Exp $
 */

#include "tclInt.h"
#include "tclPort.h"
#ifdef MAC_TCL
#include "tclMacInt.h"
#endif
2781
2782
2783
2784
2785
2786
2787


















































2788
2789
2790
2791
2792
2793
2794
	    if (Tcl_FSAccess(pathPtr, R_OK) != 0) {
		Tcl_AppendResult(interp, "couldn't load library \"",
				 Tcl_GetString(pathPtr), "\": ", 
				 Tcl_PosixError(interp), (char *) NULL);
		return TCL_ERROR;
	    }
	    


















































	    /* 
	     * Get a temporary filename to use, first to
	     * copy the file into, and then to load. 
	     */
	    copyToPtr = TclpTempFileName();
	    if (copyToPtr == NULL) {
	        return -1;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
	    if (Tcl_FSAccess(pathPtr, R_OK) != 0) {
		Tcl_AppendResult(interp, "couldn't load library \"",
				 Tcl_GetString(pathPtr), "\": ", 
				 Tcl_PosixError(interp), (char *) NULL);
		return TCL_ERROR;
	    }
	    
#ifdef TCL_LOAD_FROM_MEMORY
	/* 
	 * The platform supports loading code from memory, so ask for a
	 * buffer of the appropriate size, read the file into it and 
	 * load the code from the buffer:
	 */
	do {
            int ret, size;
            void *buffer;
            Tcl_StatBuf statBuf;
            Tcl_Channel data;
            
            ret = Tcl_FSStat(pathPtr, &statBuf);
            if (ret < 0) {
                break;
            }
            size = (int) statBuf.st_size;
            /* Tcl_Read takes an int: check that file size isn't wide */
            if (size != (Tcl_WideInt)statBuf.st_size) {
                break;
            }
	    data = Tcl_FSOpenFileChannel(interp, pathPtr, "r", 0666);
            if (!data) {
                break;
            }
            buffer = TclpLoadMemoryGetBuffer(interp, size);
            if (!buffer) {
                Tcl_Close(interp, data);
                break;
            }
            Tcl_SetChannelOption(interp, data, "-translation", "binary");
            ret = Tcl_Read(data, buffer, size);
            Tcl_Close(interp, data);
            ret = TclpLoadMemory(interp, buffer, size, ret, handlePtr, unloadProcPtr);
            if (ret == TCL_OK) {
		if (*handlePtr == NULL) {
		    break;
		}
                if (sym1 != NULL) {
                    *proc1Ptr = TclpFindSymbol(interp, *handlePtr, sym1);
                }
                if (sym2 != NULL) {
                    *proc2Ptr = TclpFindSymbol(interp, *handlePtr, sym2);
                }
		return TCL_OK;
	    }
	} while (0); 
	Tcl_ResetResult(interp);
#endif

	    /* 
	     * Get a temporary filename to use, first to
	     * copy the file into, and then to load. 
	     */
	    copyToPtr = TclpTempFileName();
	    if (copyToPtr == NULL) {
	        return -1;