I would like my app to test whether there is already a file at certain path before trying to upload a file to that path.
How could I do that?
I have an array called sortedFiles. Then I have
int i = 0;
do{
NSString *fileName = [NSString stringWithFormat:@"Pace audio/%@", [[sortedFiles objectAtIndex:i] objectForKey: @"path"]];
DBPath *newPath = [[DBPath root]childPath:fileName];
DBFile *file = [[DBFilesystem sharedFilesystem] createFile:newPath error:nil];
if ( ) //and some sort of test here to see if the file already exists at this path
[file writeContentsOfFile:fileName shouldSteal:NO error:nil];
else {
NSLog(@"File already exists");
}
NSLog(@"The number is %d", i);
i++;
}
while (i < sortedFiles.count);
I've been searching the documentation and I can't think of a way to do this. At the moment, I just get an error saying a file already exists, so at least the file isn't being overwritten.
Ideas?
Thanks.