15
edits
No edit summary |
No edit summary |
||
| Line 18: | Line 18: | ||
# var data = new File("/etc/passwd").open("r").read(); | # var data = new File("/etc/passwd").open("r").read(); | ||
# var data = new Directory("/etc").listFiles(); | # var data = new Directory("/etc").listFiles(); | ||
# var path = new Path("/home").join("ondras"); assert(path.exists()); | # var path = new Path("/home").join("ondras"); <br/> assert(path.exists()); | ||
# var path = new Path("/a/b/c"); <br/> if (path.isDirectory()) { doSomething(); } | # var path = new Path("/a/b/c"); <br/> if (path.isDirectory()) { doSomething(); } | ||
== Troubles == | == Troubles == | ||
There are still several points in this proposal which make me uncomfortable. Perhaps a different point of view or a discussion can make things clear in this area. | There are still several points in this proposal which make me uncomfortable. Perhaps a different point of view or a discussion can make things clear in this area. | ||
* It is unclear how should one convert between various Filesystem-related classes. Two solutions come to my mind: | |||
*# var dir = new Path("/etc").toDirectory(); | |||
*# var dir = new Directory(new Path("/etc/")); | |||
Both are problematic. The first one states that a Path should offer toXXX() methods, which is incorrect - as a top class, Path should not depend on existence of any of its descendants. The second way, on the other hand, is less readable. | |||
* It is unclear how moving, copying and removing should be implemented. In my original proposal, these are methods of Path object. However, as the real file/directory manipulation might be (in some way) specific to the object in question, it seems logical to have these implemented in each movable/copyable/removable class. | |||
edits