mirror of
https://github.com/transmission/transmission.git
synced 2025-12-25 04:45:56 +00:00
Add support to libtransmission and the MacOS X GUI for saving private copies of
torrent files.
This commit is contained in:
@@ -93,3 +93,54 @@ void * tr_memmem( const void *vbig, size_t big_len,
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int tr_mkdir( char * path )
|
||||
{
|
||||
char * p, * pp;
|
||||
struct stat sb;
|
||||
int done;
|
||||
|
||||
p = path;
|
||||
while( '/' == *p )
|
||||
p++;
|
||||
pp = p;
|
||||
done = 0;
|
||||
while( ( p = strchr( pp, '/' ) ) || ( p = strchr( pp, '\0' ) ) )
|
||||
{
|
||||
if( '\0' == *p)
|
||||
{
|
||||
done = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
*p = '\0';
|
||||
}
|
||||
if( stat( path, &sb ) )
|
||||
{
|
||||
/* Folder doesn't exist yet */
|
||||
if( mkdir( path, 0777 ) )
|
||||
{
|
||||
tr_err( "Could not create directory %s (%s)", path,
|
||||
strerror( errno ) );
|
||||
*p = '/';
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if( ( sb.st_mode & S_IFMT ) != S_IFDIR )
|
||||
{
|
||||
/* Node exists but isn't a folder */
|
||||
tr_err( "Remove %s, it's in the way.", path );
|
||||
*p = '/';
|
||||
return 1;
|
||||
}
|
||||
if( done )
|
||||
{
|
||||
break;
|
||||
}
|
||||
*p = '/';
|
||||
p++;
|
||||
pp = p;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user