Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Blakeasd

macrumors 6502a
Original poster
Dec 29, 2009
643
0
Hello,
In part of my application I would like to have a SVN downloading feature,
here is my code but it's not working:
Code:
-(IBAction)downloadSVN:(id)sender{
    
    NSString *svnAddRaw;
    svnAddRaw = [svnField stringValue];
    const char *svnAdd = [svnAddRaw UTF8String];
    system(svnAdd);
    



}

Does anyone know whats wrong, also how can I use a progress indicator to show the progress of the SVN download?
Thanks
 

chown33

Moderator
Staff member
Aug 9, 2009
10,739
8,415
A sea of green
1. Provide basic information.
2. Apply basic debugging skills.

http://www.mikeash.com/getting_answers.html

Exactly what does "it's not working" mean? You expected it to do something, what does it do instead? Does it crash? Return an error message? If so, exactly what error message.

Show the value of svnAddRaw. What do you expect it to be? Is it what you expect?

Since system() will interpret the string using a shell (read the man page for system), are there any quotes or other characters that could cause a shell to misinterpret the string?
 

balamw

Moderator emeritus
Aug 16, 2005
19,366
979
New England
The problem is nothing is downloading.

Often, when you call system, you don't have the same path as you do in Terminal so you may need to add "/usr/bin/" in front of svn. Also, what is your current working directory when system fires?

Have you considered using NSTask instead of system?

EDIT:

Code:
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>

int main (void) {

const char *svnAdd = "svn co https://paintbrush.svn.sourceforge.net:443/svnroot/paintbrush/Paintbrush2/branches/";

chdir("/Users/balamw/Desktop/deleteme_folder");
system(svnAdd);
}

works fine for me as a test program. Does it also work for you? (you'll need to change the directory to chdir to).

B
 
Last edited:

Blakeasd

macrumors 6502a
Original poster
Dec 29, 2009
643
0
Thanks @balamw it works now. One question though this is a feature in an app that will be deployed on other systems, obviously the systems will have different user names (yours was balamw), how can I resolve this issue? Is there a general "name" that will work with everything?
 

balamw

Moderator emeritus
Aug 16, 2005
19,366
979
New England
Thanks @balamw it works now. One question though this is a feature in an app that will be deployed on other systems, obviously the systems will have different user names (yours was balamw), how can I resolve this issue? Is there a general "name" that will work with everything?

In general you should try to give your user the option to put the file wherever they would like.

You can default it to somewhere in the user home folder a.k.a. "~" or $HOME using stringByExpandingTildeInPath. http://developer.apple.com/library/mac/#qa/qa2007/qa1549.html

B
 

Blakeasd

macrumors 6502a
Original poster
Dec 29, 2009
643
0
Last Question :D

Is it possible to show the progress of the download?
Sorry for so many questions ;)
 

balamw

Moderator emeritus
Aug 16, 2005
19,366
979
New England
Last Question :D

Is it possible to show the progress of the download?
Sorry for so many questions ;)

Not really. system is a black box. You ask it to do something for you and it comes back when it's done or tells you it didn't work.

You'd have to either redirect stdout or monitor the file system and have a separate thread to monitor it to get some kind of progress monitor and it still wouldn't know how much it is going to try and get.

B
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.