Jump to content
  • Advertisement
Sign in to follow this  
AcidZombie24

mkdir

This topic is 3703 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

weird problem. i have a createFolder func that creates every folder one by one to the full path. for example "/opt/here/new fold/last/file.txt" would create opt if needed and work its way up to last. Right now, it last is missing and everything up to exist. when i mkdir i get the error EEXIST as expected. When it finally gets to last i get ENOENT, WTF!?! man 2 mkdir says [ENOENT] A component of the path prefix does not exist or path is an empty string. everything before last exist, so... wtf?! i tried using both /opt/here/new fold/last and /opt/here/new fold/last/ both get me that error. Whats going on?

Share this post


Link to post
Share on other sites
Advertisement
I'm guessing you're using a recursive function... Could you post your code? Maybe you're traversing the list of folders to create backwards?

Share this post


Link to post
Share on other sites
Nope, i have a fake mkdir for win32 and it works perfectly there.

I was using a fake mkdir that takes in 1 param (used for windows). I just realized it called mkdir(sz, 0), so maybe 0 is causing the problem?

PS: how do i find the error variable when i get the error value? i dont like doing what i did below.


size_t fs_createSubs(const char*sz)
{
std::string s = sz, s2;
size_t pos=3;
while (1)
{
size_t a, b, c;
a = s.find("\\", pos);
b = s.find("/", pos);
c = min(a, b);
if (c == -1u)
break;

pos = c+1;
s2 = s.substr(0, c);
// s2 += "/";
if (mkdir(s2.c_str(), 0))
{
int a=errno, b;
if (a == EEXIST)
printf("%d\n", b);
b++;
if (a == EACCES)
printf("%d\n", b);
b++;
if (a == EFAULT)
printf("%d\n", b);
b++;
if (a == ELOOP)
printf("%d\n", b);
b++;
if (a == ENAMETOOLONG)
printf("%d\n", b);
b++;
if (a == ENOENT)
printf("%d\n", b);
b++;
if (a == ENOMEM)
printf("%d\n", b);
b++;
if (a == ENOSPC)
printf("%d\n", b);
b++;
if (a == ENOTDIR)
printf("%d\n", b);
b++;
if (a == EPERM)
printf("%d\n", b);
b++;
if (a == EROFS)
printf("%d\n", b);
b++;
}
}
return 0;
}


Share this post


Link to post
Share on other sites
I found the solution

It was an access error, i dont know why i got ENOENT instead of EACCES :|
It was an NTFS fs (im on mac) and i didnt realize i uninstall ntfs3g days before. (i forget what the problem was, i thought ntfs3g was tied to it, it wasnt)

installed it and my code works great.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!