Re: How check for "path/file exists"?

new topic     » goto parent     » topic index » view thread      » older message » newer message

TESTING FOR A VALID PATH

Dan,

  The problem with opening a file to test for validity is that you
  can't open a directory name, so here's what i use:

--------------------------------------------------------------

   --  Path Validation Check  --

--  checks for valid directory or filename

--------------------------------------------------------------

include file.e
include get.e --for this sample only

atom retv,ink

function ValidatePath(sequence TargetPathName,sequence TargetFileName)

  object DirEntries

  DirEntries=dir(TargetPathName&TargetFileName)
  if atom(DirEntries) then
    --doesnt exist
    return 0
  else
    return 1
  end if
end function

--testing for a valid specific filename:
?retv

--testing for a valid directory name:
?retv


printf(1,"%s\n",{"Press a key..."})

ink=wait_key()

----------------------------------------------------------------

Good luck.
  --Al

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu