platform/platform_filesystem.c
/*  Creates a folder at the given path.
*/
Creates a folder at the given path.
Creates a folder at the given path .
bool plCreateDirectory(const char *ccPath)
{
	pFUNCTION_START
#ifdef _WIN32
	if(CreateDirectory(ccPath,NULL) || (GetLastError() == ERROR_ALREADY_EXISTS))
		return true;
	else if(GetLastError() == ERROR_PATH_NOT_FOUND)
		plSetError("Failed to find an intermediate directory! (%s)\n", ccPath);
	else    
		plSetError("Unknown error! (%s)\n", ccPath);
#else	
	{
		struct stat ssBuffer;
		if(stat(ccPath,&ssBuffer) == -1)
		{
			if(mkdir(ccPath,0777) == 0)
				return true;
			else
			{
				switch(errno)
				{
				case EACCES:
					plSetError("Failed to get permission! (%s)\n",ccPath);
				case EROFS:
					plSetError("File system is read only! (%s)\n",ccPath);
				case ENAMETOOLONG:
					plSetError("Path is too long! (%s)\n",ccPath);
				default:
					plSetError("Failed to create directory! (%s)\n",ccPath);
				}
			}
		}
		else
			return true;
	}
#endif
	return false;
	pFUNCTION_END
}
bool plCreateDirectory ( const char * ccPath ) { pFUNCTION_START #ifdef _WIN32 if ( CreateDirectory ( ccPath , NULL ) || ( GetLastError ( ) == ERROR_ALREADY_EXISTS ) ) return true ; else if ( GetLastError ( ) == ERROR_PATH_NOT_FOUND ) plSetError ( " \n " , ccPath ) ; else plSetError ( " \n " , ccPath ) ; #else { struct stat ssBuffer ; if ( stat ( ccPath , & ssBuffer ) == -1 ) { if ( mkdir ( ccPath , 0777 ) == 0 ) return true ; else { switch ( errno ) { case EACCES : plSetError ( " \n " , ccPath ) ; case EROFS : plSetError ( " \n " , ccPath ) ; case ENAMETOOLONG : plSetError ( " \n " , ccPath ) ; default : plSetError ( " \n " , ccPath ) ; } } } else return true ; } #endif return false ; pFUNCTION_END }
Creates a folder at the given path.
Creates a folder at the given path .
// Assume it already exists. // TODO: Won't the below code work fine on Windows too?? // Path already exists, so this is fine.