Feb-03-2019, 12:42 AM
(Feb-02-2019, 10:13 AM)Larz60+ Wrote:that's how big the file is. now run a script that generates a random number from 64 to 1048576 (not necessarily a power of 2). append a random number of zero-bytes to the file. the file is now larger but the data is still all there. now the script i need to make would be able to determine the approximate size of the data (exact size if the data happened to end in a non-zero byte).>>> from pathlib import Path >>> home = Path('.') >>> Noc = home / 'NocturneinC-sharpMinorFredericChopinPiano.mp4' >>> Noc.stat().st_size 9017139 >>>
suppose the original file's last byte is 0x46. suppose the random number happens to be 5417. there will be 5417 bytes appended, changing the above results to 9022556. the length of the file will be 9022556 but the length to be determined is 9017139. 9017139 is the length of the data. the posix command
truncate -s 9017139 ...
applied to the appended file would be able to restore the file to its original size. but you need to know the value 9017139. if all you get is the file with appended zero bytes, you won't know until you read the file contents and look for that last non-zero byte. the program i need to create is going to determine this for all the files but not (yet) truncate any of them.if any of the original files happen to end in a zero byte (0x00) or a run of them, then the original size cannot be determined. but it is known that there will be a non-zero byte in the last 64 bytes. the units of this data are not larger than 64 and have a non-zero length prefix (e.g. its length counts itself).
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.