Find the answer to your Linux question:
Results 1 to 3 of 3
Are there some convenient ways to judge a filename is a file or directory in standard C. I have an unhandy way is using fopen to test the filename. if ...
  1. #1
    Just Joined!
    Join Date
    Nov 2008
    Posts
    2

    file or directory?

    Are there some convenient ways to judge a filename is a file or directory in standard C.

    I have an unhandy way is using fopen to test the filename. if fopen succeeds, it's a file, otherwise it's a directory.

    any help will be deeply appreciated!

  2. #2
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568

    Smile

    Yes.Use stat() and then determine the file type.

    Check this link :
    File Attributes - The GNU C Library
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  3. #3
    Just Joined!
    Join Date
    Nov 2008
    Posts
    2
    Quote Originally Posted by Lakshmipathi View Post
    Yes.Use stat() and then determine the file type.

    Check this link :
    File Attributes - The GNU C Library
    Ah! I get it, thank U so much.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...