Skip to content

Instantly share code, notes, and snippets.

@H2CO3
Created August 3, 2013 22:14
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save H2CO3/6148191 to your computer and use it in GitHub Desktop.
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.
} 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