Created
August 3, 2013 22:14
-
-
Save H2CO3/6148191 to your computer and use it in GitHub Desktop.
Patch for https://github.com/xslim/mobileDeviceManager to support copying files *from* the device. Insert this at line 75 into Source/main.m.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
} else if ([option isEqualToString:@"copyFrom"]) { | |
NSLog(@"Copying..."); | |
AFCApplicationDirectory *appDir = [device newAFCApplicationDirectory:[arguments stringForKey:@"app"]]; | |
AFCFileReference *infile = [appDir openForRead:[arguments stringForKey:@"from"]]; | |
if (!infile) { | |
NSLog(@"Error: %@", [appDir lasterror]); | |
} | |
char buf[0x10000]; | |
int outfile = open([arguments stringForKey:@"to"].UTF8String, O_CREAT | O_WRONLY, 0777); | |
uint32_t len; | |
while ((len = [infile readN:sizeof buf bytes:buf]) > 0) { | |
NSLog(@"Copied %" PRIu32 " bytes", len); | |
char *p = buf; | |
while (len) { | |
size_t readb = write(outfile, p, len); | |
p += readb; | |
len -= readb; | |
} | |
} | |
close(outfile); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment