Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

FTPgetFileSize return values

Posted on 2009-04-15
4
Medium Priority
?
2,214 Views
Last Modified: 2013-11-17
Could someone please enlighten me as to what high/low means in the description of this function? So how do you retrieve the filesize then? The description seems a bit scarce. To me at least.

MSDN says:

Parameters
hFile [in]
Handle returned from a call to FtpOpenFile.

lpdwFileSizeHigh [out]
Pointer to the high-order unsigned long integer of the file size of the requested FTP resource.

Return Value
Returns the low-order unsigned long integer of the file size of the requested FTP resource.

---

Actually, I don't have the slightest clue as to why am I required to multiply fileSize by 260. (see in the example.) Apparently, that's the way it should be calculated. So the final filesize is the sum of the aforementioned product and the return value of the function.
//Progress bar maximum
SizeLo = FtpGetFileSize(
  hFileOnFTP,
  fileSize
);
 
PbarMax = ((INT)fileSize* 260) + SizeLo;

Open in new window

0
Comment
Question by:Kyanzes
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 35

Accepted Solution

by:
Duncan Roe earned 2000 total points
ID: 24153329
The interface allows you to receive a file size of up to 64 bits which is too big to fit in a 32-bit unsigned long integer. On a 32-bit platform, unsigned long is usually the same size as unsigned int (i.e. sizeof(unsugned long) == sizeof(unsigned int) == 4). On these platforms, the compiler sometimes offers [unsigned] long long as a 64-bit entity, into which you could accumulate the file size.
Multiplying by 260 is a nonsense - you have to shift left by 32 bits. Casting to INT if INT is 32 bits will give you a zero result so is also wrong. Is fileSize a pointer? - you should not cast it to INT then. If it is not a pointer then you should have got a compiler error on FtpGetFileSize(). Since you get no error, I assume fileSize is of type INT*.
You might well be able to treat nonzero upper file size an error - do you really want to FTP files > 4GB? To actually deal properly with them supposing you don't want to limit file size, try as below. UINT64 is my invention - you'll have to search for what's available. PbarMax should be of type UINT64, and the code sets it to the file size in bytes - it will require scaling to make a progress bar. I have also changed fileSize to be of type UINT (i.e. UINT32) - SizeLo should be UINT32 also. You are doing bitwise operations so use | rather than +
//Progress bar maximum
SizeLo = FtpGetFileSize(
  hFileOnFTP,
  &fileSize
);
 
PbarMax = ((UINT64)fileSize << 32) | SizeLo;

Open in new window

0
 
LVL 49

Expert Comment

by:DanRollins
ID: 24153541
To be complete:
Multiplying the filesize value by 260 will work most of the time, since the value of that variable will be 0 most of the time. :-)
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question