mkdir

Started by
3 comments, last by AcidZombie24 15 years, 8 months ago
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?
<SkilletAudio> Your framerate proves your lack of manhood
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?
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;}
<SkilletAudio> Your framerate proves your lack of manhood
what should i use as the 2nd param of mkdir? i tried googling but didnt find anything that wasnt php or cmd line
<SkilletAudio> Your framerate proves your lack of manhood
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.
<SkilletAudio> Your framerate proves your lack of manhood

This topic is closed to new replies.

Advertisement