Use user catalog in sync
[pithos-macos] / pithos-macos / PithosUtilities.m
index 91de07d..d48928a 100644 (file)
     return YES;
 }
 
-// Removes contents of a directory
-+ (void)removeContentsAtPath:(NSString *)dirPath {
+// Removes contents of a directory and the directory itself if selected
++ (void)removeContentsAtPath:(NSString *)dirPath andDirectory:(BOOL)removeDirectory {
     NSFileManager *fileManager = [NSFileManager defaultManager];
     NSError *error = nil;
     BOOL isDirectory;
             }
             error = nil;
         }
+        if (removeDirectory && (![fileManager removeItemAtPath:dirPath error:&error] || error)) {
+            [self fileActionFailedAlertWithTitle:@"Remove Directory Error"
+                                         message:[NSString stringWithFormat:@"Cannot remove directory at '%@'", dirPath]
+                                           error:error];
+        }
     } else if (![fileManager removeItemAtPath:dirPath error:&error] || error) {
         [self fileActionFailedAlertWithTitle:@"Remove File Error" 
                                      message:[NSString stringWithFormat:@"Cannot remove file at '%@'", dirPath] 
     }
 }
 
+// Removes contents of a directory
++ (void)removeContentsAtPath:(NSString *)dirPath {
+    [self removeContentsAtPath:dirPath andDirectory:NO];
+}
+
 // Returns if an object is a directory based on its content type
 + (BOOL)isContentTypeDirectory:(NSString *)contentType {
     return ([contentType isEqualToString:@"application/directory"] ||