1. Directory Exists??
- Posted by ZNorQ <znorq at holhaug.com> Feb 08, 2007
- 509 views
I'm trying to create a function that checks the existence of a directory, but I haven't found my luck yet.. Can anyone help? Kenneth aka ZNorQ
2. Re: Directory Exists??
- Posted by Jerry Story <jstory at ocii.com> Feb 08, 2007
- 498 views
ZNorQ wrote: > > I'm trying to create a function that checks the existence of a directory, > but I haven't found my luck yet.. > > Can anyone help? > > Kenneth aka ZNorQ The Euphoria dir() It returns -1 if no file or directory with this name is found. If it is found, then you would need to check the attributes to find out whether it is a file or a directory.
3. Re: Directory Exists??
- Posted by ZNorQ <znorq at holhaug.com> Feb 09, 2007
- 498 views
Jerry Story wrote: > > ZNorQ wrote: > > > > I'm trying to create a function that checks the existence of a directory, > > but I haven't found my luck yet.. > > > > Can anyone help? > > > > Kenneth aka ZNorQ > > The Euphoria dir() > > It returns -1 if no file or directory with this name is found. > If it is found, then you would need to check the attributes to find out > whether > it is a file or a directory. Yeah, I saw that, but I was hoping there was an other command, since this would actually use time to create an index of the content (don't it?). I would like a function that uses as little time as possible to just confirm if a FOLDER exists. Thanks anyway. :) ZNorQ
4. Re: Directory Exists??
- Posted by Larry Miller <larrymiller at sasktel.net> Feb 09, 2007
- 493 views
The following is probably the simpleist and fastest method with native Euphoria functions:
function directoryExists(sequence path) sequence currentdir integer status,void currentdir=current_dir() status=chdir(path) if status then void=chdir(currentdir) end if return status end function
Tested with Windows but should also work on Linux. A faster method is possible using the windows api function FindFirstFile() but it is more complex. Larry Miller
5. Re: Directory Exists??
- Posted by don cole <doncole at pacbell.net> Feb 09, 2007
- 502 views
Larry Miller wrote: > > The following is probably the simpleist and fastest method with native > Euphoria > functions: > > }}} <eucode> > function directoryExists(sequence path) > sequence currentdir > integer status,void > currentdir=current_dir() > status=chdir(path) > if status then > void=chdir(currentdir) > end if > return status > end function > </eucode> {{{ > > Tested with Windows but should also work on Linux. > > A faster method is possible using the windows api function FindFirstFile() but > it is more complex. > > Larry Miller Tested and works for me. I don't know how fast.
global function exist(sequence fileOrFolder) object x x=dir(fileOrFolder) if atom(x) then return 0 else return 1 end if end function
Don Cole
6. Re: Directory Exists??
- Posted by ZNorQ <znorq at holhaug.com> Feb 12, 2007
- 509 views
Larry Miller wrote: > > The following is probably the simpleist and fastest method with native > Euphoria > functions: > > }}} <eucode> > function directoryExists(sequence path) > sequence currentdir > integer status,void > currentdir=current_dir() > status=chdir(path) > if status then > void=chdir(currentdir) > end if > return status > end function > </eucode> {{{ > > Tested with Windows but should also work on Linux. > > A faster method is possible using the windows api function FindFirstFile() but > it is more complex. > > Larry Miller Sounds good, don't mind if I implemend it - do you? :) Thanks. Kenneth aka ZNorQ