harangzsolt33 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; use warnings; # shorten file to 50GB: truncate "K:\\LINUX\\SparkyLinux.bin", 50000000000;
And I was surprised, because nothing happened! And truncate doesn't even have a return value about whether it succeeded or not. Well, it was evident that it failed. But why??? I then booted into Sparky Linux 7.2 which is a Debian based 64-bit Linux with Perl 5.36, and I typed the following and it worked perfectly:
truncate "/media/owner/DATA 2TB/LINUX/SparkyLinux.bin", 50000000000;
Now, I have used truncate() function before in Windows on much smaller files and it worked. So, I'm wondering if maybe the truncate() function does not work in Windows XP when we're dealing with larger files? I tried to write this same code in other languages, and those codes failed too. Weird...
I have been aware that QBASIC 1.1 in DOS has a limitation of 2GB when it comes to reading/writing binary files, and it's because they store the file pointer in a signed long, which goes from -2 billion to +2 billion. That forces a limit on how far you can move the file pointer for read and write operations. The LOF() function which returns the file size in QBASIC is also affected by issue, because it returns a negative value every time you're checking a file's size that is greater than 2GB. Looks like these older operating systems can't deal with big numbers correctly. :/
|
---|