Changeset 982


Ignore:
Timestamp:
Apr 14, 2010 6:12:04 PM (11 years ago)
Author:
toby
Message:

Fix Resource fork on Mac

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsascmds.tcl

    r976 r982  
    28082808    # assign an app to the data file, if the app and the
    28092809    # required tool (Rez) are installed
    2810     set app [file join $expgui(gsasdir) expgui.app]
    2811     if {[file exists /Developer/Tools/Rez]} {
    2812         set RezApp /Developer/Tools/Rez
    2813     } elseif {[file exists [file join $expgui(gsasexe) Rez]]} {
    2814         set RezApp [file join $expgui(gsasexe) Rez]
    2815     } else {
    2816         set RezApp {}
    2817     }
    2818     if {[file exists /Developer/Tools/SetFile]} {
    2819         set SetFileApp /Developer/Tools/SetFile
    2820     } elseif {[file exists [file join $expgui(gsasexe) SetFile]]} {
    2821         set SetFileApp [file join $expgui(gsasexe) SetFile]
    2822     } else {
    2823         set SetFileApp {}
    2824     }
     2810    set app [file nativename [file join $expgui(gsasdir) expgui.app]]
     2811    set RezApp {}
     2812    foreach pth "/usr/bin  /Developer/Tools/Rez $expgui(gsasexe)" {
     2813        if [file exists [set tst [file join $pth Rez]]] {
     2814            set RezApp $tst
     2815            break
     2816        }
     2817    }
     2818    set SetFileApp {}
     2819    foreach pth "/usr/bin  /Developer/Tools/Rez $expgui(gsasexe)" {
     2820        if [file exists [set tst [file join $pth SetFile]]] {
     2821            set SetFileApp $tst
     2822            break
     2823        }
     2824    }
     2825    if $::expgui(debug) {puts "found app=$app Rez=$RezApp and SetFile=$SetFileApp"}
    28252826    if {[file exists $app] && $RezApp != ""} {
    2826         # make a resource file
     2827        # make a resource file. Note that OS X has gotten picky about the length of this
    28272828        set l [string length $app]; incr l
    28282829        set str "data 'usro' (0) {\n"
    2829         append str {  $"}
     2830        append str "  $\""
    28302831        append str [format %.8X $l]
     2832        set bytes 4
    28312833        foreach char [split $app {}] {
    28322834           append str [format %.2X [scan $char %c]]   
    28332835        }
    2834         append str {00"}
    2835         append str " \t/* ....$app. */\n};"
     2836        incr bytes $l
     2837        set newline 1
     2838        for {set i 0} {$i < [expr 1028-$bytes]} {incr i} {
     2839            if $newline {
     2840                append str "\" \n"
     2841                append str "  $\""
     2842                set newline 0
     2843                set j 0
     2844            }
     2845            append str {0000 }
     2846            incr bytes
     2847            incr j 2
     2848            if {$j > 15} {set newline 1}
     2849        }
     2850        append str "00\"\n "
     2851        append str "/* $app */\n};\n"
    28362852        set fp [open setapp.r w]
    28372853        puts $fp $str
    28382854        close $fp
     2855        if $::expgui(debug) {puts "$RezApp setapp.r -o $expnative -a"}
    28392856        exec $RezApp setapp.r -o $expnative -a
    2840         file delete -force setapp.r
     2857        if {! $::expgui(debug)} {
     2858            file delete -force setapp.r
     2859        }
    28412860    }
    28422861
     
    28462865        exec $RezApp [file nativename $icon] -o $expnative -a
    28472866        exec $SetFileApp -a C $expnative
     2867        if {$::expgui(debug)} {
     2868            puts "$RezApp [file nativename $icon] -o $expnative -a"
     2869            puts "$SetFileApp -a C $expnative"
     2870        }
     2871    } elseif {$::expgui(debug)} {
     2872        puts "icon=$icon missing?"
    28482873    }
    28492874}
Note: See TracChangeset for help on using the changeset viewer.