Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does it mean "regular file" according to S_ISREG C/C++?

Tags:

c++

c

file

unix

Let's consider the following 3 code lines:

struct stat buffer;       
status = lstat(file.c_str(), &buffer);  
bool Flag = S_ISREG(buffer.st_mode)

When S_ISREG() returns true it tells you that the file is a regular file

What does regular means exactly ?

Thanks

like image 915
Debugger Avatar asked Apr 19 '10 14:04

Debugger


People also ask

What is a regular file in C?

A regular file is one type of file stored in a file system. It is called "regular" primarily to distinguish it from other special types of files. Most files used directly by a human user are regular files. For example, executable files, text files, and image files are regular files.

How do you tell if a file is a directory C?

The isDir() function is used to check a given file is a directory or not. Here we used stat() function and S_ISREG() macro.

How do you check if a file is a symlink in C?

S_ISLNK() macro can be used for to test whether a directory is symbolic link or it can be used to check only whether a file is symbolic link or not.


2 Answers

It is non-standard, you should check the documentation for your CRT implementation. But it ought to mean that the name refers to a regular file, instead of a pipe, stream, symbolic link, directory or device.

like image 104
Hans Passant Avatar answered Sep 24 '22 13:09

Hans Passant


Regular means it's not a directory, not a symlink, not a block device, and not a character device. It's just... regular. :)

like image 38
falstro Avatar answered Sep 23 '22 13:09

falstro