@ -66,12 +66,24 @@ int PathIsRelative(const char *path)
return PathIsAbsolute ( path ) ? 0 : 1 ;
}
/** \brief Recursively create missing log directories.
* \ param path path to log file
/**
* \ brief Wrapper around SCMkDir with default mode arguments .
*/
int SCDefaultMkDir ( const char * path )
{
return SCMkDir ( path , S_IRWXU | S_IRGRP | S_IXGRP ) ;
}
/**
* \ brief Recursively create a directory .
*
* \ param path Path to create
* \ param final true will create the final path component , false will not
*
* \ retval 0 on success
* \ retval - 1 on error
*/
int SCCreateDirectoryTree ( const char * path )
int SCCreateDirectoryTree ( const char * path , const bool final )
{
char pathbuf [ PATH_MAX ] ;
char * p ;
@ -88,7 +100,7 @@ int SCCreateDirectoryTree(const char *path)
/* Truncate, while creating directory */
* p = ' \0 ' ;
if ( SC MkDir( pathbuf , S_IRWXU | S_IRGRP | S_IXGRP ) ! = 0 ) {
if ( SC Default MkDir( pathbuf ) ! = 0 ) {
if ( errno ! = EEXIST ) {
return - 1 ;
}
@ -98,5 +110,13 @@ int SCCreateDirectoryTree(const char *path)
}
}
if ( final ) {
if ( SCDefaultMkDir ( pathbuf ) ! = 0 ) {
if ( errno ! = EEXIST ) {
return - 1 ;
}
}
}
return 0 ;
}