Revision: 40563
          http://brlcad.svn.sourceforge.net/brlcad/?rev=40563&view=rev
Author:   starseeker
Date:     2010-09-14 20:57:55 +0000 (Tue, 14 Sep 2010)

Log Message:
-----------
OK, this time we're using the Tcl functionality - can normalize paths now.

Modified Paths:
--------------
    brlcad/branches/cmake/src/libtclcad/tclcadAutoPath.c

Modified: brlcad/branches/cmake/src/libtclcad/tclcadAutoPath.c
===================================================================
--- brlcad/branches/cmake/src/libtclcad/tclcadAutoPath.c        2010-09-14 
20:00:28 UTC (rev 40562)
+++ brlcad/branches/cmake/src/libtclcad/tclcadAutoPath.c        2010-09-14 
20:57:55 UTC (rev 40563)
@@ -182,6 +182,10 @@
 {
     struct bu_vls auto_path;
     struct bu_vls lappend;
+    struct bu_vls tclcmd;
+    struct bu_vls invocation_full_path;
+    struct bu_vls root_full_path;
+    struct bu_vls build_full_path;
     const char *library_path = NULL;
 
     const char *root = NULL;
@@ -197,6 +201,14 @@
     int found_itcl_tcl = 0;
     int found_itk_tcl = 0;
 
+    Tcl_Obj *invocationPathPtr;
+    Tcl_Obj *rootPathPtr;
+    Tcl_Obj *buildPathPtr;
+
+    char *resolvedargv0;
+    char *resolvedrootdir;
+    char *resolvedbuilddir;
+
     char pathsep[2] = { BU_PATH_SEPARATOR, '\0' };
 
     if (!interp) {
@@ -209,7 +221,11 @@
 
     bu_vls_init(&auto_path);
     bu_vls_init(&lappend);
-
+    bu_vls_init(&tclcmd);
+    bu_vls_init(&invocation_full_path);
+    bu_vls_init(&root_full_path);
+    bu_vls_init(&build_full_path);
+ 
     /* determine if TCLCAD_LIBRARY_PATH is set */
     library_path = getenv("TCLCAD_LIBRARY_PATH");
     if (library_path) {
@@ -227,22 +243,33 @@
     if (!which_argv) {
        which_argv = bu_argv0_full_path();
     }
-    char resolvedargv0[MAXPATHLEN];
-    char resolvedroot[MAXPATHLEN];
-    char resolvedbuilddir[MAXPATHLEN];
-    realpath(which_argv, resolvedargv0);
-    printf("string of invocation binary: %s\n", resolvedargv0);
-    realpath(root, resolvedroot);
-    printf("root: %s\n", resolvedroot);
-    realpath(BUILD_BINARY_DIR, resolvedbuilddir);
-    printf("root: %s\n", resolvedbuilddir);
 
-    if(strstr(resolvedargv0, resolvedbuilddir))
+    bu_vls_sprintf(&tclcmd, "file normalize %s", which_argv); 
+    Tcl_Eval(interp, bu_vls_addr(&tclcmd));
+    bu_vls_sprintf(&invocation_full_path, "%s", 
Tcl_GetStringFromObj(Tcl_GetObjResult(interp), NULL));
+
+    bu_vls_sprintf(&tclcmd, "file normalize %s", root); 
+    Tcl_Eval(interp, bu_vls_addr(&tclcmd));
+    bu_vls_sprintf(&root_full_path, "%s", 
Tcl_GetStringFromObj(Tcl_GetObjResult(interp), NULL));
+
+    bu_vls_sprintf(&tclcmd, "file normalize %s", BUILD_BINARY_DIR); 
+    Tcl_Eval(interp, bu_vls_addr(&tclcmd));
+    bu_vls_sprintf(&build_full_path, "%s", 
Tcl_GetStringFromObj(Tcl_GetObjResult(interp), NULL));
+
+    printf("string of invocation binary: %s\n", 
bu_vls_addr(&invocation_full_path));
+    printf("root: %s\n", bu_vls_addr(&root_full_path));
+    printf("build: %s\n", bu_vls_addr(&build_full_path));
+    if(strstr(bu_vls_addr(&invocation_full_path), 
bu_vls_addr(&build_full_path)))
        printf("Running from build directory\n");
 
-    if(strstr(resolvedargv0, resolvedroot))
+    if(strstr(bu_vls_addr(&invocation_full_path), 
bu_vls_addr(&root_full_path)))
        printf("Running from installed directory\n");
-    
+
+    bu_vls_free(&tclcmd);
+    bu_vls_free(&invocation_full_path);
+    bu_vls_free(&root_full_path);
+    bu_vls_free(&build_full_path);
+ 
     /* get name of installation binary */
     snprintf(buffer, MAX_BUF, "%s%cbin%c%s", root, BU_DIR_SEPARATOR, 
BU_DIR_SEPARATOR, bu_getprogname());
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to