tags:

views:

176

answers:

2

Hello all,

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

+2  A: 

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

roe
+1  A: 

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.

Hans Passant
right, forgot the pipes and sockets.
roe
what about executable file ? Is it regular also ?
We still don't know your operating system. But typically, yes.
Hans Passant
ok i see, I'm working on linux
What about if i want to ignore executables, is there a way ?
Can't you just look at the filename extension?
Hans Passant
hmm no, because the executables can have regular name in my case ( without extension )
I found a way to do this, by doing a logic 'And' between buffer.st_mode and S_IXUSR ...Thanks for the help