Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
316 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// AFCache+FileAttributes.h | ||
// AFCache | ||
// | ||
// Created by Sebastian Grimme on 17.05.16. | ||
// Copyright © 2016 Artifacts - Fine Software Development. All rights reserved. | ||
// | ||
|
||
#import <AFCache/AFCache.h> | ||
|
||
@interface AFCache (FileAttributes) | ||
- (uint64_t)setContentLengthForFileAtPath:(NSString*)filePath; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// AFCache+FileAttributes.m | ||
// AFCache | ||
// | ||
// Created by Sebastian Grimme on 17.05.16. | ||
// Copyright © 2016 Artifacts - Fine Software Development. All rights reserved. | ||
// | ||
|
||
#import "AFCache+FileAttributes.h" | ||
|
||
#import "AFCacheableItem+FileAttributes.h" | ||
#import "AFCache+PrivateAPI.h" | ||
#import "AFCache_Logging.h" | ||
#include <sys/xattr.h> | ||
|
||
@implementation AFCache (FileAttributes) | ||
|
||
- (uint64_t)setContentLengthForFileAtPath:(NSString*)filePath { | ||
NSError* err = nil; | ||
NSDictionary* attrs = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:&err]; | ||
if (err) { | ||
AFLog(@"Could not get file attributes for %@", filename); | ||
return 0; | ||
} | ||
uint64_t fileSize = [attrs fileSize]; | ||
if (0 != setxattr(filePath.fileSystemRepresentation, kAFCacheContentLengthFileAttribute, &fileSize, sizeof(fileSize), 0, 0)) { | ||
AFLog(@"Could not set content length for file %@", filename); | ||
return 0; | ||
} | ||
return fileSize; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.