Add support to libtransmission and the MacOS X GUI for saving private copies of

torrent files.
This commit is contained in:
Josh Elsasser
2006-06-09 19:53:35 +00:00
parent 5ac8e113c3
commit 0600f3d4aa
26 changed files with 444 additions and 158 deletions

View File

@@ -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;
}