Erlang Central

Difference between revisions of "Split File Path"

From ErlangCentral Wiki

m (reverted spam... mmm...)
(3 intermediate revisions by 2 users not shown)

Revision as of 15:37, 14 June 2007


You want to split a path into all of its components.


The split function in the Erlang standard library module file will do this.

1> filename:split("C:\\winnt\\system32\\drivers\\etc").


You may want to find the path from the root directory to the item of interest. To do so, you will need to convert any relative pathnames to absolute path names, using the filename:absname function:

1> filename:split( filename:absname( "..\\..\\winnt\\system32\\drivers\\etc" )).
 "Program Files",