Hi
After some discussion on #parrot, and after Leo direct me to this link:
http://mail.python.org/pipermail/python-dev/2006-January/060026.html
Follows some discussion on File.pmc.
1) What it is now.
At the moment we have two OS dependent PMCs: OS and File.
OS includes stat, mkdir, remove, link, symlink, umask, chdir.
File includes is_dir, is_file, is_link, copy, rename
Both PMCs are static classes (no objects, just methods)
2) What it might be.
My first idea is to join both PMCs, and create a FileSystem PMC. The
main problem is its name. After looking to Python discussion, and
thinking a little on the PIR syntax, I would call it Path.
That way, we could have things like:
$P0 = new .Path("/foo/bar")
$P0.mkdir()
$P0.remove()
$P0.link("new/file") ## or $P0.link($P1) where $P1 is a Path
object, or both
$P0.symlink("new/file")
...
$P0.is_dir()
$P0.is_file()
$P0.copy("copy")
and so on.
I am not sure, but I think it would be also possible to:
$S0 = $P0 # get filename
$P0 = $S1 # change object... similar to 'new .Path($S1)'
If we want to mask dos/linux/mac, we can use
$P0 = new .Path("foo","bar")
so that Parrot uses the correct separator.
3) Implementation
Some discussion have taken place before regarding copy and rename
implementation. I think we can subclass this PMC for specific OSes, and
specific FileSystems if needed.
Cheers
ambs
--
Alberto Simões - Departamento de Informática - Universidade do Minho
Campus de Gualtar - 4710-057 Braga - Portugal