The iTunesFileSharing folder is simply the document folder. You can retrieve the path by executing this code:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *folderPath = [paths objectAtIndex:0];
Then you can run through the files available into the document folder and test their extension to check if they are AVI files:
- (BOOL)existsMovieFilesAtPath:(NSString *)folderPath
{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error = nil;
NSArray *contents = [fileManager contentsOfDirectoryAtPath:folderPath error:&error];
if (error == nil)
{
for (NSString *contentPath in contents)
{
NSString *fileExt = [contentPath pathExtension];
// If the current file is an AVI file
if ([fileExt isEqualToString:@"avi"])
{
return YES;
}
}
}
return NO;
}
And to delete the files you can make the same things:
- (BOOL)deleteFilesAtPath:(NSString *)folderPath
{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error = nil;
NSArray *contents = [fileManager contentsOfDirectoryAtPath:folderPath error:&error];
if (error == nil)
{
for (NSString *contentPath in contents)
{
[fileManager removeItemAtPath:contentPath error:NULL];
}
}
return NO;
}