Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

FTPgetFileSize return values

Posted on 2009-04-15
4
Medium Priority
?
2,229 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
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

886 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