MFC, large file (more than 2 GB) Get File Size bug

Source: Internet
Author: User

Today, when we split large files, we found a strange phenomenon:

1. Use a 5 K file to test the splitting to a file with a maximum size of 1 K.

2. When a 2.2g file is used for testing and split into a file with a maximum of 2 GB, seven 2 GB files and a small file are generated.

After one-step debugging, it is found that the size of the original 2.gb file is larger than 17 GB.

The function for getting the file size from the original error is:

Code:
  1. Ulonglong getfilesize (lpctstr szfilename)
  2. {
  3. Cfilestatus FS;
  4. If (! Cfile: getstatus (szfilename, FS) return 0;
  5. Return fs. m_size;
  6. }

 

And then modify it:

Code:
  1. Ulonglong getfilesize (lpctstr szfilename)
  2. {
  3. CFileFind finder; // File Search Class
  4. If (! Finder. FindFile (szFileName) return 0;
  5. Finder. FindNextFile ();
  6. ULONGLONG ul = finder. GetLength ();
  7. Finder. Close ();
  8. Return ul;
  9. }

 

After modification, the split function is normal.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.