X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=Categories%2FNSFileManager%2BUniqueNames.h;fp=Categories%2FNSFileManager%2BUniqueNames.h;h=82c57d40fee9af61d19b49dc450dc2410f0a8a7b;hp=0000000000000000000000000000000000000000;hb=0064c1fbff36795885a9724081af2a17d83c20a3;hpb=56d825ba259066d847a9fc3f9c8c0c0a362a1507 diff --git a/Categories/NSFileManager+UniqueNames.h b/Categories/NSFileManager+UniqueNames.h new file mode 100644 index 0000000..82c57d4 --- /dev/null +++ b/Categories/NSFileManager+UniqueNames.h @@ -0,0 +1,26 @@ +// +// NSFileManager+UniqueNames.h +// Enjoyable +// +// Created by Joe Wreschnig on 3/7/13. +// +// + +#import + +@interface NSFileManager (UniqueNames) + +- (NSURL *)generateUniqueURLWithBase:(NSURL *)canonical; + // Generate a probably-unique URL by trying sequential indices, e.g. + // file://Test.txt + // file://Test (1).txt + // file://Test (2).txt + // and so on. + // + // The URL is only probably unique. It is subject to the usual + // race conditions associated with generating a filename before + // actually opening it. It also does not check remote resources, + // as it operates synchronously. Finally, it gives up after 10,000 + // indices. + +@end