how to check if directory/file exist using c/c++ | Unix Linux Forums | Programming

  Unix/Linux Go Back    


Programming Post questions about C, C++, Java, SQL, and other programming languages here.

how to check if directory/file exist using c/c++

Programming


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 01-02-2006
steven88 steven88 is offline
Registered User
 
Join Date: Jan 2006
Last Activity: 3 January 2006, 1:56 AM EST
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
how to check if directory/file exist using c/c++

Hi there,

how to check if directory/file exist using c/c++ under linux/unix. Thanks.

Steven
Sponsored Links
    #2  
Old Unix and Linux 01-02-2006
vino's Unix or Linux Image
vino vino is offline Forum Advisor  
Supporter (in vino veritas)
 
Join Date: Feb 2005
Last Activity: 12 March 2015, 5:33 AM EDT
Location: Sydney, Down Under
Posts: 2,848
Thanks: 0
Thanked 13 Times in 13 Posts
Use the stat call.


Code:
struct stat st;
if(stat("/tmp",&st) == 0)
        printf(" /tmp is present\n");

Sponsored Links
    #3  
Old Unix and Linux 01-03-2006
steven88 steven88 is offline
Registered User
 
Join Date: Jan 2006
Last Activity: 3 January 2006, 1:56 AM EST
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you!

vino,
Thank you very much.
Steven
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to check file exist in a directory or not sravan008 Shell Programming and Scripting 5 07-21-2011 01:57 AM
check the directory exist ust Shell Programming and Scripting 7 09-22-2008 08:49 PM
To check whether a directory is exist and if it is not, create it sabya Shell Programming and Scripting 3 09-20-2008 02:23 PM
How to check directory exist on servers weonpc Shell Programming and Scripting 2 03-06-2008 05:29 AM
how to check if directory/file exist using c/c++ steven88 Shell Programming and Scripting 1 01-02-2006 09:45 PM



All times are GMT -4. The time now is 08:55 AM.