1. You are viewing our forum as a guest. For full access please Register. WindowsBBS.com is completely free, paid for by advertisers and donations.

usage of findfirst on NT platform

Discussion in 'Other PC Software' started by courious george, 2004/12/29.

Thread Status:
Not open for further replies.
  1. 2004/12/29
    courious george

    courious george Inactive Thread Starter

    Joined:
    2004/07/21
    Messages:
    17
    Likes Received:
    0
    I am trying to make a utility to list all files created after a given date.
    this utility will search through subdirectories. I am using the C function findfirst.

    done = findfirst(file_path, &ffblk, FA_NORMAL | FA_DIREC);

    this should find normal files or directories, unfortunatly when I set these attributies "FA_NORMAL | FA_DIREC" the function retutns -1 {a failed search}

    if I use
    done = findfirst(file_path, &ffblk, FA_NORMAL);
    the function will find only find files.

    I am working on a system
    X85 family 5 model 2 stepping 6
    NT 4.00.1381
    Borland C++Builder 5.0

    What am I missing
     
  2. 2004/12/30
    BenMcDonald[MS]

    BenMcDonald[MS] Inactive

    Joined:
    2004/12/14
    Messages:
    228
    Likes Received:
    0
    NT 4.00.1381
    Borland C++Builder 5.0

    What am I missing


    A good compiler and a supported operating system! :D

    I don't normally use the runtime versions of this function, but each compiler has thier own little quirks on it. In the microsoft implementation, you are responsible for doing your own filtering.

    Based on a quick web search, you are trying to | those flags together and thats whats causing your problem. Just add FA_DIREC, and you will get dirs and files. The below call should return everything you want. do your own processing on the .ff_attrib yourself.

    findfirst(file_path, &ffblk, FA_DIREC);


    http://web.archive.org/web/20080113...x.org/~jakov/community.borland.com/16646.html

    Problem:
    When using findfirst with the FA_DIREC attribute, I get
    regular DOS files in addition to the directories. How
    do I get just the directories?
    Solution:
    Using FA_DIREC doesn't mean *only* return directories;
    it means include directories along with regular files.
    The solution is to check each ffblk found against the
    FA_DIREC attribute.
     

  3. to hide this advert.

Thread Status:
Not open for further replies.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.