On Mon, 11 Feb 2013 00:13:00 +0100
Giuliano Colla <giuliano.co...@fastwebnet.it> wrote:

>[...]
> 3) But if also the *path* to the file doesn't yet exist, it just crashes 
> without rising an exception that the user application can handle somehow.

I get an exception in this case:
  inifile:=TIniFile.Create('/does/not/exist/bla.ini');
  inifile.WriteString('Sec','First','1');
  inifile.UpdateFile;

 
> This is rather unpleasant, because the path provided by GetAppConfigXx 
> does usually exist, so you have an application which 99% of the times 
> works just fine, and 1% of the times crashes without telling why.

Even if the directory exists the write may fail. So you must use a
try..except anyway.

 
> This was perhaps tolerable when GetAppPathConfigXx did not exist, and it 
> was developer responsibility to provide a reasonable path, taking into 
> account different target system, but today I'd expect TIniFile to take 
> care also of forcing the appropriate path, and to raise an exception if 
> it fails.


Mattias
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to