I have a reader from the file "foo" using C ++ using:
pFile = fopen ("foo" , "r");
I want it to stop the rest of the function if the file is a named pipe. Is there a way to check if a file is a named pipe before opening it?
I found the same question using python: Check if file is a named pipe (fifo) in python? Can I do something like this in C ++?
From man 2 stat:
man 2 stat
int fstat(int filedes, struct stat *buf);... The following POSIX macros are defined for checking the file type using the st_mode field: S_ISFIFO(m) FIFO (named pipe)?
int fstat(int filedes, struct stat *buf);
... The following POSIX macros are defined for checking the file type using the st_mode field:
S_ISFIFO(m) FIFO (named pipe)?
struct stat st;... !fstat(fileno(pFile, &st) && S_ISFIFO(st.st_mode) struct stat st;... !fstat(fileno(pFile, &st) && S_ISFIFO(st.st_mode) .
struct stat st;... !fstat(fileno(pFile, &st) && S_ISFIFO(st.st_mode)
: . SzG .
, AFTER fopen(). , syscall open() , - FIFO . stat() syscall ( Unix/Linux) fopen(), .
fopen()
open()
stat()
Source: https://habr.com/ru/post/1524613/More articles:Search Oracle database for row with output - sqlОтключить положительную/отрицательную кнопку в DialogFragment - androidWindows Azure - gets stuck at startup (Provisioning) when creating a virtual machine from a user-created image in the gallery - imageAnti-aliasing / merging time slots - sql-serverFacebook login - if a user account is present (and the application is not installed), login is not performed - iosSocket.io испускает не всегда получаемый результат в среде Node.js + Redis + Heroku (несколько динамиков) - node.jsHow can I use a DataTrigger to run a storyboard? - animationC ++ overload resolution for const member functions - c ++How to remove all undefined keys from a javascript array (hopefully when creating an array?) - javascriptHow ruby interpreter interprets double quotes - ruby | fooobar.comAll Articles