DSDirectoryFetcher
The DSDirectoryFetcher
class is a utility class that retrieves a list of files from a specified directory based on certain criteria. It inherits from the DSProactiveImageSourceAdapter
class.
Definition
Assembly: DynamsoftUtility.xcframework
- Objective-C
- Swift
NS_SWIFT_NAME(DirectoryFetcher) @interface DSDirectoryFetcher : DSProactiveImageSourceAdapter
class DirectoryFetcher : ProactiveImageSourceAdapter
Methods
Method | Description |
---|---|
init |
Create an instance of DSDirectoryFetcher. |
setDirectory |
Sets the directory path and filter for the file search. |
setPages |
Set the pages to read. |
The following methods are inherited from DSProactiveImageSourceAdapter
.
Method | Description |
---|---|
setImageFetchInterval |
Sets the time interval for the ImageSource to wait before attempting to fetch another image to put in the buffer. |
getImageFetchInterval |
Gets the time interval for the ImageSource to wait before attempting to fetch another image to put in the buffer. |
The following methods & attributes are inherited from DSImageSourceAdapter
.
Attributes | Type | Description |
---|---|---|
bufferEmpty |
BOOL | The read only property determines whether the buffer is currently empty. |
bufferOverflowProtectionMode |
DSBufferOverflowProtectionMode | Sets the behavior for handling new incoming images when the buffer is full. |
colourChannelUsageType |
colourChannelUsageType | Sets the usage type for color channels in images. |
hasNextImageToFetch |
BOOL | Determines whether there are more images available to fetch. |
imageCount |
NSUInteger | The property defines the current number of images in the buffer. |
maxImageCount |
NSUInteger | The property defines the maximum number of images that can be buffered. |
Method | Description |
---|---|
addImageToBuffer |
Adds an image to the internal buffer. |
clearBuffer |
Clears all images from the buffer, resetting the state for new image fetching. |
getImage |
Get a buffered image. Implementing classes should return a Promise that resolves with an instance of DSImageData . |
hasImage |
Checks if an image with the specified ID is present in the buffer. |
setErrorListener |
Sets an error listener to receive notifications about errors that occur during image source operations. |
setNextImageToReturn |
Sets the processing priority of a specific image. This can affect the order in which images are returned by getImage . |
startFetching |
Start fetching images from the source to the Video Buffer of ImageSourceAdapter. |
stopFetching |
Stop fetching images from the source to the Video Buffer of ImageSourceAdapter. |
init
Create an instance of DSDirectoryFetcher.
- Objective-C
- Swift
- (instancetype)init;
init()
Return Value
An instance of DSDirectoryFetcher
.
Code Snippet
- Objective-C
- Swift
DSDirectoryFetcher *fetcher = [[DSDirectoryFetcher alloc] init];
let fetcher = DirectoryFetcher()
setDirectory
Sets the directory path and filter for the file search.
- Objective-C
- Swift
- (BOOL)setDirectory:(NSString *)directoryPath filter:(nullable NSString *)filter recursive:(BOOL)recursive error:(NSError * _Nullable * _Nullable)error;
func setDirectory(_ directoryPath: String, filter: String?, recursive: Bool) throws
Parameters
directoryPath
: The directory path.
filter
: A string that specifies file extensions. It determines which kinds of files to read. e.g “*.BMP;*.JPG;*.GIF”.
recursive
: Specifies whether to load files recursively.
error
: An NSError
pointer. If an error occurs, it will represent the error information.
Error
Error Code | Value | Description |
---|---|---|
EC_READ_DIRECTORY_FAILED | -10064 | Failed to read the directory. |
Return Value
A BOOL
value that indicates whether the directory is set successfully.
Code Snippet
- Objective-C
- Swift
NSError *error; BOOL success = [fetcher setDirectory:directoryPath filter:nil recursive:YES error:&error];
do { try fetcher.setDirectory(directoryPath, filter: nil, recursive: true) } catch { // Add your code to deal with exceptions. }
setPages
Set the pages to read.
- Objective-C
- Swift
-(BOOL)setPages:(NSArray *)pages error:(NSError *_Nullable *_Nullable)error;
func setPages(_ pages: NSArray) throws -> BOOL
Parameters
pages
: An array that contains all the pages to read.
error
: An NSError
pointer. If an error occurs, it will represent the error information.
Error
Error Code | Value | Description |
---|---|---|
EC_FILE_NOT_FOUND | -10005 | File not found. |
EC_FILE_TYPE_NOT_SUPPORTED | -10006 | The file type is not supported. |
EC_IMAGE_READ_FAILED | -10012 | Failed to read the image. |