mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
gpg: Make progress work for large files on Windows.
* common/iobuf.c (iobuf_get_filelength): Change return type to uint64_t and remove the overflow args. For Windows always use GetFileSizeEx which is available since the long EOL-ed Windows XP. * g10/sign.c (write_plaintext_packet): Adjust for changed iobuf_get_filelength. * g10/encrypt.c (encrypt_simple, encrypt_crypt): Ditto. * g10/photoid.c (generate_photo_id): Ditto. Also add an upper limit. * g10/filter.h (progress_filter_context_t): Change amount values to use uint64_t. * g10/progress.c (write_status_progress): Change accordingly. -- GnuPG-bug-id: 6534
This commit is contained in:
parent
695cb04af5
commit
808494b485
8 changed files with 52 additions and 86 deletions
|
@ -2608,13 +2608,10 @@ iobuf_set_limit (iobuf_t a, off_t nlimit)
|
|||
}
|
||||
|
||||
|
||||
|
||||
off_t
|
||||
iobuf_get_filelength (iobuf_t a, int *overflow)
|
||||
/* Return the length of the file behind A. If there is no file, return 0. */
|
||||
uint64_t
|
||||
iobuf_get_filelength (iobuf_t a)
|
||||
{
|
||||
if (overflow)
|
||||
*overflow = 0;
|
||||
|
||||
/* Hmmm: file_filter may have already been removed */
|
||||
for ( ; a->chain; a = a->chain )
|
||||
;
|
||||
|
@ -2627,56 +2624,18 @@ iobuf_get_filelength (iobuf_t a, int *overflow)
|
|||
gnupg_fd_t fp = b->fp;
|
||||
|
||||
#if defined(HAVE_W32_SYSTEM)
|
||||
ulong size;
|
||||
static int (* __stdcall get_file_size_ex) (void *handle,
|
||||
LARGE_INTEGER *r_size);
|
||||
static int get_file_size_ex_initialized;
|
||||
LARGE_INTEGER exsize;
|
||||
|
||||
if (!get_file_size_ex_initialized)
|
||||
{
|
||||
void *handle;
|
||||
|
||||
handle = dlopen ("kernel32.dll", RTLD_LAZY);
|
||||
if (handle)
|
||||
{
|
||||
get_file_size_ex = dlsym (handle, "GetFileSizeEx");
|
||||
if (!get_file_size_ex)
|
||||
dlclose (handle);
|
||||
}
|
||||
get_file_size_ex_initialized = 1;
|
||||
}
|
||||
|
||||
if (get_file_size_ex)
|
||||
{
|
||||
/* This is a newer system with GetFileSizeEx; we use this
|
||||
then because it seem that GetFileSize won't return a
|
||||
proper error in case a file is larger than 4GB. */
|
||||
LARGE_INTEGER exsize;
|
||||
|
||||
if (get_file_size_ex (fp, &exsize))
|
||||
{
|
||||
if (!exsize.u.HighPart)
|
||||
return exsize.u.LowPart;
|
||||
if (overflow)
|
||||
*overflow = 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((size=GetFileSize (fp, NULL)) != 0xffffffff)
|
||||
return size;
|
||||
}
|
||||
if (GetFileSizeEx (fp, &exsize))
|
||||
return exsize.QuadPart;
|
||||
log_error ("GetFileSize for handle %p failed: %s\n",
|
||||
fp, w32_strerror (-1));
|
||||
#else /*!HAVE_W32_SYSTEM*/
|
||||
{
|
||||
struct stat st;
|
||||
struct stat st;
|
||||
|
||||
if ( !fstat (fp, &st) )
|
||||
return st.st_size;
|
||||
log_error("fstat() failed: %s\n", strerror(errno) );
|
||||
}
|
||||
if ( !fstat (fp, &st) )
|
||||
return st.st_size;
|
||||
log_error("fstat() failed: %s\n", strerror(errno) );
|
||||
#endif /*!HAVE_W32_SYSTEM*/
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue