broken is pathinfo

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

The pathinfo function in filesys.e is broken. Thanks to Kat for reporting this problem.

There is a similar thread "pathinfo is broken," but I am having trouble following all of the lines of thought in that thread. My simplistic approach is start over again.

I am testing with Eu4.0.5 on Mint14.

include std/console.e 
include std/filesys.e 
 
object info 
info = pathinfo("C:\\euphoria\\docs\\readme.txt") 
display( info ) 
 
--{ 
--  "", 
--  "C:\\euphoria\\docs\\readme.txt", 
--  "C:\\euphoria\\docs\\readme", 
--  "txt", 
--  "" 
-- } 

So clearly this is not what the documentation suggests will happen.

I noticed that in filesys.e unix SLASHES is "/" so (under unix) this function can not produce a correct result.

include std/console.e 
include std/filesys.e 
 
object info 
 
info = pathinfo("C:/euphoria/docs/readme.txt") 
display( info ) 
 
--{ 
--  "C:/euphoria/docs", 
--  "readme.txt", 
--  "readme", 
--  "txt", 
--  "" 
--} 

This is still wrong but closer to the expected result.

What remains is why "C:" is not parsed.

Some detail missing from the documentation:

std_slash can be -1 to use / on Linux and \ on Windows, or you can specify "/" or "\\" ('/' and '\\' should behave the same), or in fact any other character or string of your choice. The default (0) is to leave path separators unaltered.

It looks like filesys:pathinfo needs another ticket.

Related existing ticket:

Euphoria Ticket #870: filesys:pathinfo strips drive letter on windows

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

Search



Quick Links

User menu

Not signed in.

Misc Menu