473,378 Members | 1,518 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Check directory exists c++

1
Guys,
I wrote a simple code to check the existence of a directory (in UNIX based file systems) which is working for me. Have I done it in the correct way?




Expand|Select|Wrap|Line Numbers
  1.  
  2. #include <dirent.h>
  3.  
  4. bool DirectoryExists( const char* pzPath )
  5. {
  6.     if ( pzPath == NULL) return false;
  7.  
  8.     DIR *pDir;
  9.     bool bExists = false;
  10.  
  11.     pDir = opendir (pzPath);
  12.  
  13.     if (pDir != NULL)
  14.     {
  15.         bExists = true;    
  16.         (void) closedir (pDir);
  17.     }
  18.  
  19.     return bExists;
  20. }
  21.  
  22.  
Jan 5 '07 #1
0 24440

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: calca77 | last post by:
Hi, Please, could anyone tell me how to check if a directory exists. Thank you everyone. D.
1
by: Pgar | last post by:
I have a page that I have the users uploading files from their local machines. I take these files strip off their path and redirect it to a new file on the web server. I have a virtual directory...
1
by: Steven J. Reed | last post by:
I am trying to find out is a folder exists within a share on a server. I can successfully determine if a file exists within the share, but I can't figure out how to determine if it's parent folder...
2
by: Joris De Groote | last post by:
Hi How can I check if a directory exists in a network drive? I can check it on the local machine, but when I want to check a network drive, that doenst work, how can I do this? Thanks Joris
2
by: CCLeasing | last post by:
If (Directory.Exists(@"c:\indigo\" + txtOfficial + @"\" + comOffice.Text + @"\" + numTerm.Value.ToString())) { storereport(); } else { Directory.CreateDirectory(@"c:\indigo\" + txtOfficial +...
9
by: shughes | last post by:
i am not really a programmer, so i have a question on the system.io.directory.exists what i am trying to do is have a button, once this button is clicked it checks to see if the Directory...
1
by: aine_canby | last post by:
Hi, How do I check if a directory exists within another directory? For example C:/aaa C:/Aaa = true C:/aaa/ C:/Aaa/bb = true C:/aaa/ C:/Aaa/bb/cc = true C:/bb/ C:/aa/ = false
0
by: emp | last post by:
I am writing a logging function. Hourly a log entry is made into a directory for the current date. Each day a new current date directory is made. How can I check to see if a directory exists?...
4
by: ndedhia1 | last post by:
Hi. I am writing a java program in which I want to ftp a file to another unix box. First I have to check if the directory exists in which I am ftping into and if it does not exist, I have to create...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.