• R/O
  • HTTP
  • SSH
  • HTTPS

Tombo: Commit

TOMBO source code


Commit MetaInfo

Revisionfe40ba301224d986b2a25270d2caa3b1685c73f6 (tree)
Time2012-04-01 11:49:49
AuthorHirami <tomohisa.hirami@nift...>
CommiterHirami

Log Message

Remove characters from note's title which can't use file name.

Change Summary

Incremental Difference

--- a/iOS/Tombo/Tombo/Storage.m
+++ b/iOS/Tombo/Tombo/Storage.m
@@ -96,6 +96,17 @@
9696
9797 return result;
9898 }
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+}
99110
100111 - (FileItem *)decideFileName:(NSString *)titleCand path:(NSString *)origPath {
101112 FileItem *result = [FileItem alloc];
@@ -105,7 +116,7 @@
105116 NSMutableString *path = [NSMutableString stringWithCapacity:256];
106117 [path appendString:[origPath stringByDeletingLastPathComponent]];
107118 [path appendString:@"/"];
108- [path appendString:titleCand];
119+ [path appendString:[self removeInvalidFilenameChars:titleCand]];
109120 NSUInteger n = [path length];
110121 [path appendString:@"."];
111122 [path appendString:ext];
Show on old repository browser