Re: How check for "path/file exists"?
- Posted by Dan B Moyer <DANMOYER at PRODIGY.NET> Sep 04, 2000
- 481 views
Al, Oh, ok, now I understand: you're providing for making a specific check for whether a *directory* exists or not. I didn't really need that, as what I am doing is asserting a "default" pathname for Wolf's Tutorial, and if it isn't there (which I can & do check with open filename), then I open the "open file" dialog to find it & then use it. But that *is* an interesting routine you shared with us! :) Dan ----- Original Message ----- From: "Al Getz" <xaxo at AOL.COM> To: <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Monday, September 04, 2000 3:46 AM Subject: Re: How check for "path/file exists"? > 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=ValidatePath("c:\\euphoria\\projects\\tests\\","test.txt") > ?retv > > --testing for a valid directory name: > retv=ValidatePath("c:\\euphoria\\projects\\emptydir\\","*.*") > ?retv > > > printf(1,"%s\n",{"Press a key..."}) > > ink=wait_key() > > ---------------------------------------------------------------- > > Good luck. > --Al