Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 263417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:36:00+00:00 2026-05-11T22:36:00+00:00

I am trying to identify file types for directory entries (Windows Unix etc..). In

  • 0

I am trying to identify file types for directory entries (Windows Unix etc..).

In sys/stat.h the high order nybble of the st_mode word have the coded values:

#define S_IFDIR  0x4000  /* directory */
#define S_IFIFO  0x1000  /* FIFO special */
#define S_IFCHR  0x2000  /* character special */
#define S_IFBLK  0x3000  /* block special */
#define S_IFREG  0x8000  /* or just 0x0000, regular */

From the comment it seems the nybble could be either 0 or 8 to represent
a ‘regular file’.

So this begs the question: in what circumstances is it 0 and not 8?
If I had defined these codes, I would have reserved 0 to inidicate
unknown/undefined/invalid/not-a-file or something like that.

Indeed the S_ISREG macro is:

#define S_ISREG(m)  ((m) & S_IFREG)

This would seem to me to indicate that a regular file should
always be expected to have the code 8 (and 0 would be an abberation?).

Would it be a valid assumption to interpret 0 as an unknown or invalid file and ignore the ‘or just 0x0000’ comment and always expect 8 to be used for all regular files?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T22:36:00+00:00Added an answer on May 11, 2026 at 10:36 pm

    Most sources indicate that checking S_ISREG is enough; I’m not sure when you’d see 0x0000 as a “regular” file.

    I believe some old implementations used 0x0000 (a really old DJGPP header search turns this up) but it’s the only real reference I can find. Everything else points to 0x8000.

    Basically, use the S_ISREG macro and hope that the header on whatever you’re compiling against does the right thing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to identify if this is an IIS issue or a code issue.
I am trying to identify when an action without authorization has been made. Is
I am trying to identify a screen in a multi-monitor setup to save some
I am trying to identify duplicate serial numbers from the following xml using XPath
I am trying to identify all the nodes in a tree that lead to
I am trying to identify SQL INSERTS that occur when a record is viewed
I'm trying to identify when a particular process is running, based on its arguments,
I am trying to identify a problem because of an unusual usage of variadic
Using Delphi XE 2 I've trying to identify the zoom direction to apply the
Hi I am trying to identify key Twitter influencers for a client and I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.