Jump to content

file.getSize() - Always returns 0 while using linux


photo

Recommended Posts

Posted

Hello

 

 

Following code returns all the time 0:

 

// Check if file exists
   	File file = new File();
   	if(file.open( engine.getDataPath() + "settings.xml", "w+")) // -rw-rw-r-- 1 mgysin mgysin     604 Apr  3 11:00 settings.xml -> 604 Bytes
          	log.error(string(file.getSize()));

 

I have no windows client for testing, but the error occurs on linux all the time.

 

 

kind regard

Manuel

Posted

Hi,

 

This is correct behavior as 'w+' mode always truncate your file. Use 'r+' or 'a+' instead.

×
×
  • Create New...