1. file.e, dir() function and glob
- Posted by Jeremy Cowgar <jeremy at ?owgar?com> Apr 17, 2008
- 6265 views
Spawned from bug report (http://sourceforge.net/tracker/index.php?func=detail&aid=1608870&group_id=182827&atid=902782) I did some research and as already known, dir("*.abc") is not cross-platform. It only works in some cases on DOS and Windows. *.abc will return (using OpenWatcom only, as the test compiler) *.abc and *.abcd, *.abce, or whatever happens to follow *.abc. In the bug report I suggested using dir() in the POSIX manner it was intended, i.e. no wildcards... dir("."), dir(".."), dir ("\\EUPHORIA"), dir("/opt/euphoria") for example and then introduce a new function in file.e named glob, http://en.wikipedia.org/wiki/Glob_%28programming%29 ... I've created the glob function and tested it on Windows and Linux and it works just as expected. glob("*.abc") returns anything .abc, not everything .abc and .abcd. But the real benefit is it works on Windows, Linux and presumably FreeBSD. I would like to commit the glob function to SVN and recommend it for a cross-platform, working solution to the dir("*.abc") problem. Does anyone have objections? -- Jeremy Cowgar http://jeremy.cowgar.com
2. Re: file.e, dir() function and glob
- Posted by Michael J. Sabal <m_sabal at ?ahoo.?om> Apr 17, 2008
- 6240 views
Jeremy Cowgar wrote: > > Spawned from bug report (<a > href="http://sourceforge.net/tracker/index.php?func=detail&aid=1608870&group_id=182827&atid=902782">http://sourceforge.net/tracker/index.php?func=detail&aid=1608870&group_id=182827&atid=902782</a>) > > > I did some research and as already known, dir("*.abc") is not cross-platform. > It only works in some cases on DOS and Windows. *.abc will return (using > OpenWatcom > only, as the test compiler) *.abc and *.abcd, *.abce, or whatever happens to > follow *.abc. > > In the bug report I suggested using dir() in the POSIX manner it was intended, > i.e. no wildcards... > dir("."), dir(".."), dir ("\\EUPHORIA"), dir("/opt/euphoria") for example and > then introduce > a new function in file.e named glob, <a > href="http://en.wikipedia.org/wiki/Glob_%28programming%29">http://en.wikipedia.org/wiki/Glob_%28programming%29</a> > ... > > I've created the glob function and tested it on Windows and Linux and it works > just as expected. > > glob("*.abc") returns anything .abc, not everything .abc and .abcd. But the > real benefit is it works on Windows, Linux and presumably FreeBSD. > > I would like to commit the glob function to SVN and recommend it for a > cross-platform, > working solution to the dir("*.abc") problem. Does anyone have objections? > > -- > Jeremy Cowgar > <a href="http://jeremy.cowgar.com">http://jeremy.cowgar.com</a> I object. By changing the existing functionality of dir, any program that depends on it using wildcards (I have several dozen) will break. I recommend that the glob function be named glob_dir to allow for future introduction of glob(sequence pattern, sequence strings). I also recommend that glob_dir be introduced immediately, but that existing dir functionality not be changed until version 3.3. Documentation for dir in version 3.1.x and 3.2 should clearly state that the behavior of the statement will be changing. This should give programmers time to adjust their code without having to scramble. Thank you, Jeremy, for taking the time to address this issue. BTW, what are you doing differently to prevent DOS and Windows from returning *.abc* when only *.abc was requested? Michael J. Sabal
3. Re: file.e, dir() function and glob
- Posted by Shawn Pringle <shawn.pringle at gm?i?.com> Apr 17, 2008
- 6265 views
To me, it is better to leave a design that could have been better in place than to change it after being in use for years and years by other people. The documentation tells of what dir() should do for the Rapid Development version of EUPHORIA. If building on different compilers produces different results use conditional compiling to make adjustments where need be to match the production version. Shawn Pringle
4. Re: file.e, dir() function and glob
- Posted by Jeremy Cowgar <jeremy at ?owgar.c?m> Apr 17, 2008
- 6280 views
Michael J. Sabal wrote: > > I object. By changing the existing functionality of dir, any program that > depends on it using wildcards (I have several dozen) will break. I recommend > that the glob function be named glob_dir to allow for future introduction of > glob(sequence pattern, sequence strings). I also recommend that glob_dir be > introduced immediately, but that existing dir functionality not be changed > until version 3.3. Documentation for dir in version 3.1.x and 3.2 should > clearly state that the behavior of the statement will be changing. This > should give programmers time to adjust their code without having to scramble. > Thank you, Jeremy, for taking the time to address this issue. BTW, what > are you doing differently to prevent DOS and Windows from returning > *.abc* when only *.abc was requested? > Michael, I am not suggesting (or in fact can) change the way the current dir works. It's a direct call to the C dir function, thus, I cannot change it. What I am suggesting is that from here on out we do not rely on it to provide *.abc type functionality, because in fact, it does not do it correctly and it's not cross-platform. An application that runs on Windows and/or DOS will still work exactly as it did. That, however could change as the Watcom compiler is aging and no longer supported. The new OpenWatcom compiler does not work the same as the old Watcom compiler works. So, a defunc dir command may come about whether we like it or not, and not due to any Euphoria change. What I am suggesting is that if you want *.abc functionality, you use a new function that is created but yet to be added called glob. The glob function will work regardless of compiler and/or platform. Now, what I am doing differently is I call dir() to get the list. I then filter the list in a for loop to remove unwanted files. I am not relying on dir to do it for me. -- Jeremy Cowgar http://jeremy.cowgar.com
5. Re: file.e, dir() function and glob
- Posted by c.k.lester <euphoric at ckle?t?r.com> Apr 17, 2008
- 6236 views
Jeremy Cowgar wrote: > > What I am suggesting is that if you want *.abc functionality, you use a new > function that is created but yet to be added called glob. The glob function > will work regardless of compiler and/or platform. I say go for it.
6. Re: file.e, dir() function and glob
- Posted by Jeremy Cowgar <jeremy at cowgar.c?m> Apr 17, 2008
- 6252 views
Hm, I could modify the dir() function to check if a wildcard exists. If so, do the wildcard in a cross-platform manner and thus, not even introduce a new function. How does that sound? Thus, dir("*.abc") will always work regardless of compiler/platform. That may be the best solution? -- Jeremy Cowgar http://jeremy.cowgar.com
7. Re: file.e, dir() function and glob
- Posted by Julio C. Galaret Viera <galaret at adi?et.com.u?> Apr 17, 2008
- 6271 views
Jeremy Cowgar wrote: > > Hm, > > I could modify the dir() function to check if a wildcard exists. If so, do the > wildcard in a cross-platform manner and thus, not even introduce a new > function. > > > How does that sound? Thus, dir("*.abc") will always work regardless of > compiler/platform. > That may be the best solution? > > -- > Jeremy Cowgar > <a href="http://jeremy.cowgar.com">http://jeremy.cowgar.com</a> I think so. JG
8. Re: file.e, dir() function and glob
- Posted by Jeremy Cowgar <jeremy at c?wgar.co?> Apr 17, 2008
- 6250 views
The dir() command as of SVN revision 307 now works properly and is cross platform. The idea of glob_dir has been scrapped and the original function fixed. -- Jeremy Cowgar http://jeremy.cowgar.com
9. Re: file.e, dir() function and glob
- Posted by Kat <KAT12 at ?oosahs.?et> Apr 18, 2008
- 6272 views
- Last edited Apr 19, 2008
Jeremy Cowgar wrote: > > Hm, > > I could modify the dir() function to check if a wildcard exists. If so, do the > wildcard in a cross-platform manner and thus, not even introduce a new > function. I changed strtok thusly: ** wildtok()** wildtok(string,token,n,separator) A more controlled matchtok(). Wildtok no longer matches abc if you ask for *a*, like it did in strtok v1. Note the difference between *a and a* and *a* in the examples. I'd not introduce glob(), i'd fix dir(). Kat
10. Re: file.e, dir() function and glob
- Posted by Jeremy Cowgar <jeremy at cowga?.?om> Apr 18, 2008
- 6243 views
- Last edited Apr 19, 2008
Kat wrote: > > I'd not introduce glob(), i'd fix dir(). > > Kat Kat, Yes, I fixed dir and committed to SVN. It now works regardless of the compiler or platform. -- Jeremy Cowgar http://jeremy.cowgar.com
11. Re: file.e, dir() function and glob
- Posted by Kat <KAT12 at coosahs.n?t> Apr 19, 2008
- 6262 views
Jeremy Cowgar wrote: > > Kat wrote: > > > > I'd not introduce glob(), i'd fix dir(). > > > > Kat > > Kat, > > Yes, I fixed dir and committed to SVN. It now works regardless of the compiler > or platform. Kool, now fix goto ? Kat
12. Re: file.e, dir() function and glob
- Posted by Jeremy Cowgar <jeremy at c?wgar.?om> Apr 19, 2008
- 6275 views
Kat wrote: > > Jeremy Cowgar wrote: > > Kat, > > > > Yes, I fixed dir and committed to SVN. It now works regardless of the > > compiler > > or platform. > > Kool, now fix goto ? > Kat, sorry, I don't follow. goto ? -- Jeremy Cowgar http://jeremy.cowgar.com
13. Re: file.e, dir() function and glob
- Posted by c.k.lester <euphoric at ckleste??com> Apr 19, 2008
- 6260 views
Jeremy Cowgar wrote: > Kat wrote: > > Jeremy Cowgar wrote: > > > Kat, > > > Yes, I fixed dir and committed to SVN. It now works regardless of the > > > compiler > > > or platform. > > Kool, now fix goto ? > Kat, sorry, I don't follow. goto ? Just smile and nod, Jeremy. :D
14. Re: file.e, dir() function and glob
- Posted by Dan Moyer <danielmoyer at ?ro?igy.net> Apr 19, 2008
- 6261 views
Jeremy Cowgar wrote: > > Kat wrote: > > > > Jeremy Cowgar wrote: > > > > Kat, > > > > > > Yes, I fixed dir and committed to SVN. It now works regardless of the > > > compiler > > > or platform. > > > > Kool, now fix goto ? > > > > Kat, sorry, I don't follow. goto ? > > -- > Jeremy Cowgar Jeremy, Kat has wanted a "goto" ADDED to Euphoria for a LONG time :) Dan Moyer