mirror of
https://github.com/transmission/transmission
synced 2024-12-23 16:24:02 +00:00
(trunk libT) #2196: add a fallback implementation of preallocateFileFull() in case the os-specific and fs-specific approaches don't work.
This commit is contained in:
parent
5300ad8ef8
commit
45f1316bce
1 changed files with 13 additions and 0 deletions
|
@ -183,6 +183,19 @@ preallocateFileFull( const char * filename, uint64_t length )
|
|||
}
|
||||
# endif
|
||||
|
||||
if( !success ) /* if nothing else works, do it the old-fashioned way */
|
||||
{
|
||||
uint8_t buf[ 4096 ];
|
||||
memset( buf, 0, sizeof( buf ) );
|
||||
success = TRUE;
|
||||
while ( success && ( length > 0 ) )
|
||||
{
|
||||
const int thisPass = MIN( length, sizeof( buf ) );
|
||||
success = write( fd, buf, thisPass ) == thisPass;
|
||||
length -= thisPass;
|
||||
}
|
||||
}
|
||||
|
||||
close( fd );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue