@@ -1707,7 +1707,7 @@ - (void)buildDataTransferItems:(std::vector<DataTransferItem> &)dataTransferItem
17071707 for (NSString *file in fileNames) {
17081708 NSURL *fileURL = [NSURL fileURLWithPath: file];
17091709 BOOL isDir = NO ;
1710- BOOL isValid = (! [[NSFileManager defaultManager ] fileExistsAtPath: fileURL.path isDirectory: &isDir] || isDir) ? NO : YES ;
1710+ BOOL isValid = [[NSFileManager defaultManager ] fileExistsAtPath: fileURL.path isDirectory: &isDir] && ! isDir;
17111711 if (isValid) {
17121712
17131713 NSString *MIMETypeString = nil ;
@@ -1727,14 +1727,6 @@ - (void)buildDataTransferItems:(std::vector<DataTransferItem> &)dataTransferItem
17271727 forKey: NSURLFileSizeKey
17281728 error: &fileSizeError];
17291729
1730- NSNumber *width = nil ;
1731- NSNumber *height = nil ;
1732- if ([MIMETypeString hasPrefix: @" image/" ]) {
1733- NSImage *image = [[NSImage alloc ] initWithContentsOfURL: fileURL];
1734- width = @(image.size .width );
1735- height = @(image.size .height );
1736- }
1737-
17381730 DataTransferItem transferItem = {
17391731 .name = fileURL.lastPathComponent .UTF8String ,
17401732 .kind = " file" ,
@@ -1746,12 +1738,10 @@ - (void)buildDataTransferItems:(std::vector<DataTransferItem> &)dataTransferItem
17461738 transferItem.size = fileSizeValue.intValue ;
17471739 }
17481740
1749- if (width != nil ) {
1750- transferItem.width = width.intValue ;
1751- }
1752-
1753- if (height != nil ) {
1754- transferItem.height = height.intValue ;
1741+ if ([MIMETypeString hasPrefix: @" image/" ]) {
1742+ NSImage *image = [[NSImage alloc ] initWithContentsOfURL: fileURL];
1743+ transferItem.width = static_cast <int >(image.size .width );
1744+ transferItem.height = static_cast <int >(image.size .height );
17551745 }
17561746
17571747 dataTransferItems.push_back (transferItem);
@@ -1768,9 +1758,9 @@ - (void)buildDataTransferItems:(std::vector<DataTransferItem> &)dataTransferItem
17681758 .kind = " image" ,
17691759 .type = MIMETypeString.UTF8String ,
17701760 .uri = RCTDataURL (MIMETypeString, imageData).absoluteString .UTF8String ,
1771- .size = imageData.length ,
1772- .width = image.size .width ,
1773- .height = image.size .height ,
1761+ .size = static_cast < int >( imageData.length ) ,
1762+ .width = static_cast < int >( image.size .width ) ,
1763+ .height = static_cast < int >( image.size .height ) ,
17741764 };
17751765
17761766 dataTransferItems.push_back (transferItem);
0 commit comments