aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPExportFileUtilities.m
diff options
context:
space:
mode:
Diffstat (limited to 'Source/SPExportFileUtilities.m')
-rw-r--r--Source/SPExportFileUtilities.m44
1 files changed, 27 insertions, 17 deletions
diff --git a/Source/SPExportFileUtilities.m b/Source/SPExportFileUtilities.m
index 561c5340..c14fd7e0 100644
--- a/Source/SPExportFileUtilities.m
+++ b/Source/SPExportFileUtilities.m
@@ -36,10 +36,13 @@ typedef enum
SPExportErrorCancelExport = 0,
SPExportErrorReplaceFiles = 1,
SPExportErrorSkipErrorFiles = 2
-} SPExportErrorChoice;
+}
+SPExportErrorChoice;
@interface SPExportController (SPExportFileUtilitiesPrivateAPI)
- - (void)_reopenExportSheet;
+
+- (void)_reopenExportSheet;
+
@end
@implementation SPExportController (SPExportFileUtilities)
@@ -130,7 +133,7 @@ typedef enum
*/
- (void)errorCreatingExportFileHandles:(NSArray *)files
{
- // Get the number of files that already exists as well as couldn't be created because of other reasons
+ // Get the number of files that already exist as well as couldn't be created because of other reasons
NSUInteger filesAlreadyExisting = 0;
NSUInteger filesFailed = 0;
@@ -138,17 +141,25 @@ typedef enum
{
if ([file exportFileHandleStatus] == SPExportFileHandleExists) {
filesAlreadyExisting++;
-
+ }
// For file handles that we failed to create for some unknown reason, ignore them and remove any
// exporters that are associated with them.
- } else if ([file exportFileHandleStatus] == SPExportFileHandleFailed) {
+ else if ([file exportFileHandleStatus] == SPExportFileHandleFailed) {
+
filesFailed++;
+
+ NSMutableArray *exportersToRemove = [[NSMutableArray alloc] init];
+
for (SPExporter *exporter in exporters)
{
if ([[exporter exportOutputFile] isEqualTo:file]) {
- [exporters removeObject:exporter];
+ [exportersToRemove addObject:exporter];
}
}
+
+ [exporters removeObjectsInArray:exportersToRemove];
+
+ [exportersToRemove release];
}
}
@@ -164,10 +175,12 @@ typedef enum
if (filesAlreadyExisting == 1) {
[alert setMessageText:[NSString stringWithFormat:NSLocalizedString(@"“%@” already exists. Do you want to replace it?", @"Export file already exists message"), [[[files objectAtIndex:0] exportFilePath] lastPathComponent]]];
[alert setInformativeText:[NSString stringWithFormat:@"%@%@", NSLocalizedString(@"A file with the same name already exists in the target folder. Replacing it will overwrite its current contents.", @"Export file already exists explanatory text"), additionalErrors]];
- } else if (filesAlreadyExisting == [exportFiles count]) {
+ }
+ else if (filesAlreadyExisting == [exportFiles count]) {
[alert setMessageText:[NSString stringWithFormat:NSLocalizedString(@"All the export files already exist. Do you want to replace them?", @"All export files already exist message")]];
[alert setInformativeText:[NSString stringWithFormat:@"%@%@", NSLocalizedString(@"Files with the same names already exist in the target folder. Replacing them will overwrite their current contents.", @"All export files already exist explanatory text"), additionalErrors]];
- } else {
+ }
+ else {
[alert setMessageText:[NSString stringWithFormat:NSLocalizedString(@"%lu files already exist. Do you want to replace them?", @"Export file already exists message"), filesAlreadyExisting]];
[alert setInformativeText:[NSString stringWithFormat:@"%@%@", [NSString stringWithFormat:NSLocalizedString(@"%lu files with the same names already exist in the target folder. Replacing them will overwrite their current contents.", @"Some export files already exist explanatory text"), filesAlreadyExisting], additionalErrors]];
}
@@ -187,20 +200,21 @@ typedef enum
[[[alert buttons] objectAtIndex:2] setKeyEquivalent:@"s"];
[[[alert buttons] objectAtIndex:2] setKeyEquivalentModifierMask:NSCommandKeyMask];
}
-
+ }
// If one or multiple files failed, but only due to unhandled errors, show a short dialog
- } else {
+ else {
if (filesFailed == 1) {
[alert setMessageText:[NSString stringWithFormat:NSLocalizedString(@"“%@” could not be created", @"Export file creation error title"), [[[files objectAtIndex:0] exportFilePath] lastPathComponent]]];
[alert setInformativeText:NSLocalizedString(@"An unhandled error occurred when attempting to create the export file. Please check the details and try again.", @"Export file creation error explanatory text")];
- } else if (filesFailed == [exportFiles count]) {
+ }
+ else if (filesFailed == [exportFiles count]) {
[alert setMessageText:[NSString stringWithFormat:NSLocalizedString(@"No files could be created", @"All export files creation error title")]];
[alert setInformativeText:NSLocalizedString(@"An unhandled error occurred when attempting to create each of the export files. Please check the details and try again.", @"All export files creation error explanatory text")];
- } else {
+ }
+ else {
[alert setMessageText:[NSString stringWithFormat:NSLocalizedString(@"%lu files could not be created", @"Export files creation error title"), filesFailed]];
[alert setInformativeText:[NSString stringWithFormat:NSLocalizedString(@"An unhandled error occurred when attempting to create %lu of the export files. Please check the details and try again.", @"Export files creation error explanatory text"), filesFailed]];
}
-
[alert addButtonWithTitle:NSLocalizedString(@"Cancel", @"cancel button")];
[[[alert buttons] objectAtIndex:0] setTag:SPExportErrorCancelExport];
@@ -303,10 +317,6 @@ typedef enum
}
}
-@end
-
-@implementation SPExportController (SPExportFileUtilitiesPrivateAPI)
-
/**
* Re-open the export sheet without resetting the interface - for use on error.
*/