@@ -670,15 +670,20 @@ FFLogoImageResult ffLogoPrintImageImpl(FFLogoRequestData* requestData, const FFI
670670 return printSuccessful ? FF_LOGO_IMAGE_RESULT_SUCCESS : FF_LOGO_IMAGE_RESULT_RUN_ERROR ;
671671}
672672
673- static int getCacheFD (FFLogoRequestData * requestData , const char * fileName )
673+ static FFNativeFD getCacheFD (FFLogoRequestData * requestData , const char * fileName )
674674{
675675 uint32_t cacheDirLength = requestData -> cacheDir .length ;
676676 ffStrbufAppendS (& requestData -> cacheDir , fileName );
677+ #ifndef _WIN32
677678 int fd = open (requestData -> cacheDir .chars , O_RDONLY
678679 #ifdef O_CLOEXEC
679680 | O_CLOEXEC
680681 #endif
681682 );
683+ #else
684+ HANDLE fd = CreateFileA (requestData -> cacheDir .chars , GENERIC_READ ,
685+ FILE_SHARE_READ , NULL , OPEN_EXISTING , FILE_ATTRIBUTE_NORMAL , NULL );
686+ #endif
682687 ffStrbufSubstrBefore (& requestData -> cacheDir , cacheDirLength );
683688 return fd ;
684689}
@@ -740,17 +745,17 @@ static bool printCachedPixel(FFLogoRequestData* requestData)
740745 return false;
741746 }
742747
743- FF_AUTO_CLOSE_FD int fd = -1 ;
748+ FF_AUTO_CLOSE_FD FFNativeFD fd = FF_INVALID_FD ;
744749 if (requestData -> type == FF_LOGO_TYPE_IMAGE_KITTY )
745750 {
746751 fd = getCacheFD (requestData , FF_CACHE_FILE_KITTY_COMPRESSED );
747- if (fd == -1 )
752+ if (fd == FF_INVALID_FD )
748753 fd = getCacheFD (requestData , FF_CACHE_FILE_KITTY_UNCOMPRESSED );
749754 }
750755 else if (requestData -> type == FF_LOGO_TYPE_IMAGE_SIXEL )
751756 fd = getCacheFD (requestData , FF_CACHE_FILE_SIXEL );
752757
753- if (fd == -1 )
758+ if (fd == FF_INVALID_FD )
754759 return false;
755760
756761 ffPrintCharTimes ('\n' , options -> paddingTop );
@@ -783,7 +788,7 @@ static bool printCachedPixel(FFLogoRequestData* requestData)
783788 {
784789 char buffer [32768 ];
785790 ssize_t readBytes ;
786- while ((readBytes = ffReadFDData (FFUnixFD2NativeFD ( fd ) , sizeof (buffer ), buffer )) > 0 )
791+ while ((readBytes = ffReadFDData (fd , sizeof (buffer ), buffer )) > 0 )
787792 ffWriteFDData (FFUnixFD2NativeFD (STDOUT_FILENO ), (size_t ) readBytes , buffer );
788793 }
789794
0 commit comments