Open Directory In C, Return File Descriptor

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • paleman
    New Member
    • Mar 2010
    • 3

    Open Directory In C, Return File Descriptor

    Hi.
    I'm trying to write my own version of opendir function on Windows XP.Within that function I'm calling open function:
    Code:
    fd = open(path, O_RDONLY, 0);
    and this fails when path points to a directory.
    Does anyone know how to open a directory on Win OS so it returns a file descriptor to it.Maybe open should be given another parameters or some other function exists that I don't know of.
  • newb16
    Contributor
    • Jul 2008
    • 687

    #2
    And what is it expected to do when you try to read from this descriptor that corespond to the directory? There are other functions that you can use to list files in a directory.

    Comment

    • paleman
      New Member
      • Mar 2010
      • 3

      #3
      I would only use it for checking weather is it a directory or not with 'fstat' function.I guess I just use 'stat' than.You are right, there are other functions, like FindFirstFile/FindNextFile.

      Comment

      • newb16
        Contributor
        • Jul 2008
        • 687

        #4
        at least for _open msdn contains the following - ( about errno result for _open())
        EACCES
        Tried to open read-only file for writing, file's sharing mode does not allow specified operations, or given path is directory.

        open() is listed as deprecated and there is no info on it, but i guess it has the same limitations. If the compiler is other than VC, and it passes file name directly to underlying win32 functions, I guess the reason is the same - directories are not supported for opening in this way.

        Comment

        Working...