From: Matthew Fernandez Date: Tue, 19 Jul 2022 02:46:29 +0000 (-0700) Subject: glcomp plugin file_exists: simplify readability test X-Git-Tag: 5.0.1~30^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a5525b52ccee7d309a0a3a42262c0e7425c70ac6;p=graphviz glcomp plugin file_exists: simplify readability test We do not need to open a file to test if it is readable. --- diff --git a/lib/glcomp/CMakeLists.txt b/lib/glcomp/CMakeLists.txt index 1ca639674..536fd05ca 100644 --- a/lib/glcomp/CMakeLists.txt +++ b/lib/glcomp/CMakeLists.txt @@ -48,6 +48,10 @@ if(with_smyrna) ${XRENDER_INCLUDE_DIRS} ) + if(WIN32 AND NOT MINGW) + target_include_directories(glcomp PRIVATE ../../windows/include/unistd) + endif() + target_link_libraries(glcomp PRIVATE ${Freetype_LIBRARIES} ${GLUT_LIBRARIES} diff --git a/lib/glcomp/glcomp.vcxproj b/lib/glcomp/glcomp.vcxproj index ec6e28e81..c654f04e9 100644 --- a/lib/glcomp/glcomp.vcxproj +++ b/lib/glcomp/glcomp.vcxproj @@ -51,7 +51,7 @@ Disabled - $(SolutionDir)windows\dependencies\libraries\x86\include;$(SolutionDir)windows\dependencies\libraries\x86\include\cairo;$(SolutionDir)lib;$(SolutionDir)lib\common;%(AdditionalIncludeDirectories) + $(SolutionDir)windows\dependencies\libraries\x86\include;$(SolutionDir)windows\dependencies\libraries\x86\include\cairo;$(SolutionDir)windows\include\unistd;$(SolutionDir)lib;$(SolutionDir)lib\common;%(AdditionalIncludeDirectories) _DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL @@ -65,7 +65,7 @@ - $(SolutionDir)windows\dependencies\libraries\x86\include;$(SolutionDir)windows\dependencies\libraries\x86\include\cairo;$(SolutionDir)lib;$(SolutionDir)lib\common;%(AdditionalIncludeDirectories) + $(SolutionDir)windows\dependencies\libraries\x86\include;$(SolutionDir)windows\dependencies\libraries\x86\include\cairo;$(SolutionDir)windows\include\unistd;$(SolutionDir)lib;$(SolutionDir)lib\common;%(AdditionalIncludeDirectories) NDEBUG;_LIB;%(PreprocessorDefinitions) Level4 diff --git a/lib/glcomp/glpangofont.c b/lib/glcomp/glpangofont.c index 02943df07..67dadc189 100644 --- a/lib/glcomp/glpangofont.c +++ b/lib/glcomp/glpangofont.c @@ -9,6 +9,7 @@ *************************************************************************/ #include +#include #define DEFAULT_FONT_FAMILY "Arial" #define DEFAULT_FONT_SIZE 32 @@ -16,12 +17,7 @@ static int file_exists(const char *filename) { - FILE *file; - if ((file = fopen(filename, "r"))) { - fclose(file); - return 1; - } - return 0; + return access(filename, R_OK) == 0; } static PangoLayout *get_pango_layout(char *markup_text,