Recent

Author Topic: $IOChecks off$  (Read 8271 times)

cazzajay

  • Jr. Member
  • **
  • Posts: 94
$IOChecks off$
« on: December 14, 2009, 01:50:36 am »
was the command in delphi for making any IO errors not raise an exception

namely i am using the mkdir command to make a directory in win32

however if the directory already exists i want the application to ignore trying to make it and use the existing directory anyway silently

is there some lazarus equivalent to this?

thanks

cj
« Last Edit: December 14, 2009, 02:04:11 am by cazzajay »
Windows XP 32 bit / Lazarus 1.0.6 / FPC 2.6.0

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: $IOChecks off$
« Reply #1 on: December 14, 2009, 02:25:09 am »
was the command in delphi for making any IO errors not raise an exception

namely i am using the mkdir command to make a directory in win32

however if the directory already exists i want the application to ignore trying to make it and use the existing directory anyway silently

is there some lazarus equivalent to this?

thanks

cj

Yes, but probably a safer approach is just to check if directory exists and, if so, don't call mkdir. Turning off exceptions probably not a good habit.

Thanks.

-Phil

Mike J

  • Jr. Member
  • **
  • Posts: 54
  • Computer Programmer/www.NewsRx.com
    • ᏣᎳᎩ ᎦᏬᏂᎯᏍᏗ ᏗᏕᎶᏆᏍᏗ (Cherokee Language Lessons)
Re: $IOChecks off$
« Reply #2 on: December 14, 2009, 04:33:03 am »
Couldn't you just use a try finally block to ignore the exception ?
ᏙᎯ

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12845
  • FPC developer.
Re: $IOChecks off$
« Reply #3 on: December 14, 2009, 08:48:54 am »
Uses procedure "Forcedirectory" (or forcedirectories)

cazzajay

  • Jr. Member
  • **
  • Posts: 94
Re: $IOChecks off$
« Reply #4 on: December 14, 2009, 12:18:00 pm »
was the command in delphi for making any IO errors not raise an exception

namely i am using the mkdir command to make a directory in win32

however if the directory already exists i want the application to ignore trying to make it and use the existing directory anyway silently

is there some lazarus equivalent to this?

thanks

cj

Yes, but probably a safer approach is just to check if directory exists and, if so, don't call mkdir. Turning off exceptions probably not a good habit.

Thanks.

-Phil


thanks phil, how do i check if it exists. i know "fileexists" but didnt realise there was a directory equivalent!

and thanks to all the other guys - if phil's suggestion works, i think it will be the most "solid" solution
Windows XP 32 bit / Lazarus 1.0.6 / FPC 2.6.0

cazzajay

  • Jr. Member
  • **
  • Posts: 94
Re: $IOChecks off$
« Reply #5 on: December 14, 2009, 01:41:54 pm »
after not being lazy and doing some research it seems you use "directoryexists".  lol.
Windows XP 32 bit / Lazarus 1.0.6 / FPC 2.6.0

 

TinyPortal © 2005-2018