PDA

View Full Version : resolve pwd //


mentality
06-02-2005, 02:44 PM
allow io to resolve (like unix) pwd with multiple /s in path from tcl, ie. ///pwd//here/etc///etx will equal /pwd/here/etc/etx

tuff
06-02-2005, 02:53 PM
and this is usefull for what?

io already has resolve functions,

resolve pwd $pwd

which will resolve /this/is/a/test to c:\site\whatever\this\is\a\test

a simply regsub/exp would remove the unneeded /`s from your pwd

mentality
06-02-2005, 03:14 PM
regsub what? {/} {//} {///} {/////}

bit infalted dont u think, and im sure if it wasnt useful, it wouldnt be part of unix. but, i guess you're bored.

heres an example:

mkd from site root, pwd is therefore: /
mkd /0day/1224/test
io args: MKD /0day/1224/test
glue em together //0day/1224/test

u can do:


set pwd /[string trim [string trim $pwd /]/[string trim [lrange $args 1 end] /] /]


but waste of time if hardcoded, just a req, not lifestyle decision, matey.

neoxed
06-02-2005, 04:31 PM
Originally posted by mentality
regsub what? {/} {//} {///} {/////}

bit infalted dont u think, and im sure if it wasnt useful, it wouldnt be part of unix. but, i guess you're bored.
Last I checked, ioFTPD is written for Windows, not UNIX (or any of its equivalents). If you were to argue your point, perhaps you should reference Windows software instead. Using Windows explorer, try to access "C:\\\\\Windows" – you will find that only “C:\Windows” works (at least on XPSP2). Now of course, this behavior is not consistent with _all_ Microsoft applications.
Originally posted by mentality
u can do:


set pwd /[string trim [string trim $pwd /]/[string trim [lrange $args 1 end] /] /]

I'm sorry, but that example code is just ugly and not practical. You could look into Tcl's 'file normalize' function, which canonicalizes the given path (beware; this function has a few subtleties).

Or even a simple regular expression replacement would suffice (as tuff mentioned):
regsub -all {[\\/]+} $dirPath {/} dirPath

darkone
06-02-2005, 06:02 PM
I think it should be able to do that.. I might be wrong though :) Now that I remember, path resolver is one of the few things left that I have not yet touched. It needs to be rewritten to support unicode... which is something I will have to do, after I'm done with rewriting the php extension ;)

mentality
06-02-2005, 06:32 PM
@neoxed, just bcos there is differences between windows and unix, doesn't mean they arent useful features to have.

@darkone, i've tried resolving pwd's with //etc//e/t, returns "", i think its a nice feature to have built in, just my 2 cents...

darkone
06-02-2005, 08:10 PM
That's rather odd, because I think that on-site those paths should work without problems? And it's using the same algorithm for resolving... really odd

mentality
06-02-2005, 08:51 PM
indeed, if i mkd via cmd line with '//////test' io will make 'test' in root