This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Newbie's problem with fopen


Hi,

after a lot of debug I realize that there was nothing
wrong with fopen at logLink, but with opendir in
makeSubDir.
makeSubDir creates the following new subdirectory. All
subdirectories are like /home/andre/001,
/home/andre/002, ...
The problem is that even though a directory exists,
sometimes opendir can't open it, and returns NULL.
Does anyone have any idea about what could be wrong?

Thanks,

Andre

int makeSubDir( const char * theDirectory, char *
newSubDirectory )
{
	int subDir = 0;
	if( opendir( theDirectory ) == 0 )
		return( -1 );

	do
	{
		subDir++;
		sprintf( newSubDirectory, "%s/%03d", theDirectory,
subDir );
	}
	while( opendir( newSubDirectory ) );

	mkdir( newSubDirectory, S_IRUSR + S_IWUSR + S_IXUSR
);
	if( opendir( newSubDirectory ) == 0 )
		return( -1 );

	return( 0 );
}

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]