mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.5 KiB
Objective-C
62 lines
1.5 KiB
Objective-C
#import <Foundation/Foundation.h>
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
// A base class that abstracts away a source of NSData
|
|
// and allows us to:
|
|
//
|
|
// * Lazy-load if possible.
|
|
// * Avoid duplicate reads & writes.
|
|
@interface DataSource : NSObject
|
|
|
|
@property (nonatomic, nullable) NSString *sourceFilename;
|
|
|
|
// Should not be called unless necessary as it can involve an expensive read.
|
|
- (NSData *)data;
|
|
|
|
// The URL for the data. Should always be a File URL.
|
|
//
|
|
// Should not be called unless necessary as it can involve an expensive write.
|
|
//
|
|
// Will only return nil in the error case.
|
|
- (nullable NSURL *)dataUrl;
|
|
|
|
// Will return zero in the error case.
|
|
- (NSUInteger)dataLength;
|
|
|
|
// Returns YES on success.
|
|
- (BOOL)writeToPath:(NSString *)dstFilePath;
|
|
|
|
- (BOOL)isValidImage;
|
|
|
|
- (BOOL)isValidVideo;
|
|
|
|
@end
|
|
|
|
#pragma mark -
|
|
|
|
@interface DataSourceValue : DataSource
|
|
|
|
+ (nullable DataSource *)dataSourceWithData:(NSData *)data fileExtension:(NSString *)fileExtension;
|
|
|
|
+ (nullable DataSource *)dataSourceWithData:(NSData *)data utiType:(NSString *)utiType;
|
|
|
|
+ (DataSource *)dataSourceWithSyncMessageData:(NSData *)data;
|
|
|
|
+ (DataSource *)emptyDataSource;
|
|
|
|
@end
|
|
|
|
#pragma mark -
|
|
|
|
@interface DataSourcePath : DataSource
|
|
|
|
+ (nullable DataSource *)dataSourceWithURL:(NSURL *)fileUrl shouldDeleteOnDeallocation:(BOOL)shouldDeleteOnDeallocation;
|
|
|
|
+ (nullable DataSource *)dataSourceWithFilePath:(NSString *)filePath
|
|
shouldDeleteOnDeallocation:(BOOL)shouldDeleteOnDeallocation;
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|