image
image

Go Back   macosx.com > Mac Help Forums > Mac OS X System & Mac Software

Reply
 
Thread Tools
  #1  
Old March 28th, 2008, 03:30 PM
Registered User
 
Join Date: Mar 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
trey5498 is on a distinguished road
Needing help with a script

I have asked 2 questions before and both times when I asked them I was given good pointers but ended up figure it out myself. I am here once again in an attempt to ask a question and hopefully be able to solve it with your help.

What I am looking for is a way to install your choice of 1 to 26 items at a time (installing multiple from the list if so choose) with a switch at the bottom to allow you to select all of them. I will need to run a check of the os since the files that need to be checked for are in 2 different spots in 10.4 and 10.5

run down on what i need:

- Check the os version and place it in the variable
- check if a file exists in the folder, if not, then copy it there
- a way to install the items that the user selects

I am attempting to use xcode, however, I was wondering if there is a better program to use. I know that i will need to have an array to copy the items to so it will be read into.

Please help me or point me in the right direction again.
Reply With Quote
  #2  
Old March 28th, 2008, 04:47 PM
Mikuro's Avatar
Crotchety UI Nitpicker
 
Join Date: Mar 2005
Posts: 2,504
Thanks: 4
Thanked 15 Times in 14 Posts
Mikuro is on a distinguished road
Have you considered building a package for use with the standard Installer.app? It sounds like what you need is what that was built for. I have little experience with it, though, so I'm not sure exactly how you'd rig it up.

If you want to deal with XCode, you can use the methods detailed at Cocoa Dev Central for testing which Mac OS version the user has. I recommend method #2 on that page. The first one won't work beyond Panther, and the last one is just complicated.

To check and copy files, look up NSFileManager. Specifically, the fileExistsAtPath:isDirectory: and copyPath:toPath:handler: methods.
__________________
Mac mini — 1.25GHz G4, 1GB RAM — OS 10.5.5

Useful programs: Privoxy, Butler, ffmpegX, VLC, Perian, Tofu, Wcalc
Reply With Quote
  #3  
Old March 30th, 2008, 01:21 PM
macbri's Avatar
Mac (r)evolution
 
Join Date: Jun 2005
Location: Ireland
Posts: 254
Thanks: 1
Thanked 0 Times in 0 Posts
macbri is on a distinguished road
Quote:
Originally Posted by Mikuro View Post
If you want to deal with XCode, you can use the methods detailed at Cocoa Dev Central for testing which Mac OS version the user has. I recommend method #2 on that page. The first one won't work beyond Panther, and the last one is just complicated.
I'm with Mikuro, I prefer method #2 as well. For the original poster to differentiate between 10.4 and 10.5 it's no problem, but for finer control it's a but lacking since it will report anything after 10.4.9 (10.4.10, 10.4.11....) the same.

So for others who find this post and might be looking for more than just the minor revision number, here's a program which uses the original code, and a proposed modification. Output on Tiger (currently 10.4.11) looks like this, where the original method reports the OS as 10.4.9, and the modification shows 10.4.11:

0x1049
10.4.11

Code:
// os.c
// Compile with:  gcc -o os os.c -framework Carbon
#include <stdio.h>
#include <Carbon/Carbon.h>

void OriginalMethod()
{
  SInt32 macVersion = 0;
  if (Gestalt(gestaltSystemVersion, &macVersion) == noErr) {
    fprintf(stderr,"0x%4x\n", macVersion);
  } else {
    fprintf(stderr,"Gestalt error\n");
  }
}

void ModifiedMethod()
{
  SInt32 osVersion[3] = {0, 0, 0};
  if (Gestalt(gestaltSystemVersionMajor, &osVersion[0]) == 
    Gestalt(gestaltSystemVersionMinor, &osVersion[1]) ==
    Gestalt(gestaltSystemVersionBugFix,&osVersion[2]) == noErr) {
    fprintf(stderr,"%d.%d.%d\n", osVersion[0], osVersion[1], osVersion[2]);
  } else {
    fprintf(stderr,"Gestalt error\n");
  }
}

int main(void)
{
  OriginalMethod();
  ModifiedMethod();
}
Edit: Interesting. I just found this in Gestalt.h (look in /System/Library/Frameworks/CoreServices.framework....)

Quote:
A better way to get version information on Mac OS X would be to read in the
system version information from the file /System/Library/CoreServices/SystemVersion.plist.
I don't have access to anything older than 10.4 any more so I don't know if this is valid in older versions of the OS. In any case SystemVersion.plist on 10.4 includes this:

Code:
        <string>Mac OS X</string>
        <key>ProductUserVisibleVersion</key>
        <string>10.4.11</string>
        <key>ProductVersion</key>
        <string>10.4.11</string>

Last edited by macbri; March 30th, 2008 at 01:29 PM. Reason: Extra info
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 05:50 PM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.