By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,852 Members | 2,240 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,852 IT Pros & Developers. It's quick & easy.

error in creating a new directory

P: 35
Hi all,
I have written a c program in which i try to create a directory using mkdir call but when i check the value of errno,sometimes it gives me 2(ENOENT) and 36(ENAMETOOLONG).what might be the the error.
this is the code:
i have given base path as /home/es/work/gsf/gulb/data/
Expand|Select|Wrap|Line Numbers
  1. sprintf(new_dir_path,"%s/%s_%08d_%d%02d%02d%02d%02d%02d/",base_path,file_tag,dir_counter,1900+now.tm_year, now.tm_mon+1,now.tm_mday,now.tm_hour,now.tm_min,now.tm_sec);
  2. if(mkdir(new_dir_path,0777) < 0)
  3.         {
  4.             if(errno != EEXIST)
  5.             {
  6.                 printf("Unable to create relative directory!! :%s,%d\n",new_dir_path,errno);
  7.                 return -1;
  8.             }
  9.         }
Mar 8 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

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