71 lines
2.4 KiB
Objective-C
71 lines
2.4 KiB
Objective-C
//
|
|
// DDLogFileInfo.h
|
|
// NVLogManagerDemo
|
|
//
|
|
// Created by cxb on 2023/5/10.
|
|
// Copyright © 2023 com.zhouxi. All rights reserved.
|
|
//
|
|
|
|
#import <Foundation/Foundation.h>
|
|
#import "DDFileLogger.h"
|
|
#import "DDLogFileInfo.h"
|
|
#import "DDLog.h"
|
|
#import <sys/xattr.h>
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
#pragma mark -
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
/**
|
|
* `DDLogFileInfo` is a simple class that provides access to various file attributes.
|
|
* It provides good performance as it only fetches the information if requested,
|
|
* and it caches the information to prevent duplicate fetches.
|
|
*
|
|
* It was designed to provide quick snapshots of the current state of log files,
|
|
* and to help sort log files in an array.
|
|
*
|
|
* This class does not monitor the files, or update it's cached attribute values if the file changes on disk.
|
|
* This is not what the class was designed for.
|
|
*
|
|
* If you absolutely must get updated values,
|
|
* you can invoke the reset method which will clear the cache.
|
|
**/
|
|
@interface DDLogFileInfo : NSObject
|
|
|
|
@property (strong, nonatomic, readonly) NSString *filePath;
|
|
@property (strong, nonatomic, readonly) NSString *fileName;
|
|
|
|
@property (strong, nonatomic, readonly) NSDictionary<NSFileAttributeKey, id> *fileAttributes;
|
|
|
|
@property (strong, nonatomic, nullable, readonly) NSDate *creationDate;
|
|
@property (strong, nonatomic, nullable, readonly) NSDate *modificationDate;
|
|
|
|
@property (nonatomic, readonly) unsigned long long fileSize;
|
|
|
|
@property (nonatomic, readonly) NSTimeInterval age;
|
|
|
|
@property (nonatomic, readonly) BOOL isSymlink;
|
|
|
|
@property (nonatomic, readwrite) BOOL isArchived;
|
|
|
|
+ (nullable instancetype)logFileWithPath:(nullable NSString *)filePath NS_SWIFT_UNAVAILABLE("Use init(filePath:)");
|
|
|
|
- (instancetype)init NS_UNAVAILABLE;
|
|
- (instancetype)initWithFilePath:(NSString *)filePath NS_DESIGNATED_INITIALIZER;
|
|
|
|
- (void)reset;
|
|
- (void)renameFile:(NSString *)newFileName NS_SWIFT_NAME(renameFile(to:));
|
|
|
|
- (BOOL)hasExtendedAttributeWithName:(NSString *)attrName;
|
|
|
|
- (void)addExtendedAttributeWithName:(NSString *)attrName;
|
|
- (void)removeExtendedAttributeWithName:(NSString *)attrName;
|
|
|
|
- (NSComparisonResult)reverseCompareByCreationDate:(DDLogFileInfo *)another;
|
|
- (NSComparisonResult)reverseCompareByModificationDate:(DDLogFileInfo *)another;
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|