1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-24 08:43:27 +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:
Charles Kerr 2009-06-16 17:10:47 +00:00
parent 5300ad8ef8
commit 45f1316bce

View file

@ -183,6 +183,19 @@ preallocateFileFull( const char * filename, uint64_t length )
} }
# endif # 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 ); close( fd );
} }