Downloading SVN System Command

Discussion in 'Mac Programming' started by Blakeasd, Feb 16, 2011.

  1. Blakeasd macrumors 6502a

    Joined:
    Dec 29, 2009
    #1
    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
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    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?
     
  3. Blakeasd thread starter macrumors 6502a

    Joined:
    Dec 29, 2009
    #3
  4. balamw, Feb 17, 2011
    Last edited: Feb 17, 2011

    balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #4
    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
     
  5. Blakeasd thread starter macrumors 6502a

    Joined:
    Dec 29, 2009
    #5
    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?
     
  6. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #6
    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
     
  7. Blakeasd thread starter macrumors 6502a

    Joined:
    Dec 29, 2009
    #7
    Last Question :D

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

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #8
    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
     

Share This Page