I am using truezip version (7.7.9) to update a archive file. The way I am doing it is as follows
File entry = new TFile(filepath);
writer = new TFileWriter(entry);
writer.append("MyString");
writer.flush();
long fileSize = entry.length(); // which always gives value as 0
I need the exact file size for some purpose But this always gives 0 Is there any other way I can get that.
I read the documentation of TFile class\ https://truezip.java.net/apidocs/de/schlichtherle/truezip/file/TFile.html#length() couldn't quite understand what it does
From the FAQ:
Every now and then you might want to treat an archive file like a regular file rather than a virtual directory. For example, when trying to obtain the length of the archive file in bytes. You would normally do this by calling the method File.length(). However, if the File object is an instance of the TFile class and the path has been detected to name a valid archive file, then this method would always return zero. This is because you might have changed the archive file and then it would be impossible to return a precise result until the changes have been committed to the target archive file.
It seems you can either compute the size of the file before changing it and then add the size of what you are appending, or you need to write the file and then call File.length()
. You can do this by calling TVFS.unmount() or TVFS.unmount(TFile)