TOMBO source code
Revision | fe40ba301224d986b2a25270d2caa3b1685c73f6 (tree) |
---|---|
Time | 2012-04-01 11:49:49 |
Author | Hirami <tomohisa.hirami@nift...> |
Commiter | Hirami |
Remove characters from note's title which can't use file name.
@@ -96,6 +96,17 @@ | ||
96 | 96 | |
97 | 97 | return result; |
98 | 98 | } |
99 | +// Remove characters which can't use file name from given string. | |
100 | +- (NSString *)removeInvalidFilenameChars:(NSString *)src { | |
101 | + NSString *result = src; | |
102 | + // chars are same as Tombo for Windows. | |
103 | + NSArray *chars = [[NSArray alloc] initWithObjects:@"\\", @"/", @":", @",", @";", @"*", @"?", @"<", @">", @"\"", @"\t", nil]; | |
104 | + | |
105 | + for (NSString *t in chars) { | |
106 | + result = [result stringByReplacingOccurrencesOfString:t withString:@""]; | |
107 | + } | |
108 | + return result; | |
109 | +} | |
99 | 110 | |
100 | 111 | - (FileItem *)decideFileName:(NSString *)titleCand path:(NSString *)origPath { |
101 | 112 | FileItem *result = [FileItem alloc]; |
@@ -105,7 +116,7 @@ | ||
105 | 116 | NSMutableString *path = [NSMutableString stringWithCapacity:256]; |
106 | 117 | [path appendString:[origPath stringByDeletingLastPathComponent]]; |
107 | 118 | [path appendString:@"/"]; |
108 | - [path appendString:titleCand]; | |
119 | + [path appendString:[self removeInvalidFilenameChars:titleCand]]; | |
109 | 120 | NSUInteger n = [path length]; |
110 | 121 | [path appendString:@"."]; |
111 | 122 | [path appendString:ext]; |