How can you tell if the metadata for a "file" is a directory or file?
I'm using the new V2 dropbox API for Objective-C. I don't see any way to distinguish between a file and directory. I'm expecting a .isDirectory
call similar to what was available in V1 of the API.
Is this API available in the Swift version of the API?
The following code lists all files and directories at the given path. (simplified, as it is ignoring "more files")
- (void)loadMetadataForPath:(NSString*)path
{
[[self.dbUserClient.filesRoutes listFolder:path ] setResponseBlock:^(DBFILESListFolderResult * _Nullable result, DBFILESListFolderError * _Nullable routeError, DBRequestError * _Nullable networkError)
{
NSArray<DBFILESMetadata*> *entries = result.entries;
NSString *cursor = result.cursor;
BOOL hasMore = result.hasMore.boolValue;
for (DBFILESMetadata *fileMetadata in entries)
{
// How do I test if this file is a directory?
// BOOL isDirectory = fileMetadata.isDirectory;
NSLog(@"Dropbox filename = %@", fileMetadata.name);
}
// Ingoring more files for simplicity
}];
}
You can use isKindOfClass
to detect the type of the entry. There's an example in the readme in the printEntries
method here.