Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #29812
| From | Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: A "current directory" concept for Java... |
| Date | 2014-08-22 23:38 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <slrnlvfl43.fp3.avl@login.logic.tuwien.ac.at> (permalink) |
| References | <slrnlvet48.fp3.avl@login.logic.tuwien.ac.at> <lt85hb$gnk$1@dont-email.me> |
Martin Gregorie <martin@address-in-sig.invalid> wrote: > On Fri, 22 Aug 2014 16:49:12 +0000, Andreas Leitgeb wrote: >> I'm fully aware, that the concept of a mutable "current directory" for >> the whole VM does not work at all well with threads, and thus there is >> of course no such thing like "System.chDir(...)" in Java. > Unless I missed something, on a Unix/Linux system the Java 'current > directory' is the directory in $PWD when the JVM is started and all > relative filenames are relative to $PWD. That's typically the initial value for the "current directory." In most languages this can be changed lateron, and in some of those other languages this interferes badly with threads, which I believe is the reason, why Java doesn't allow it to be changed lateron. > I filename os "A filename is ..." ? > relative unless it > starts with '/'. Isn't it the same on a Windows box except that an > absolute name will start with a drive designator? Well, you already named the first exception: drive letters... Old MacOS (pre-X) had relative paths start with the separator char ":" and had no special name to denote "parent" at all (but fortunately, that's mere archaeology by now). Since writing my previous post, I've found that the non-trivial parts of what I sought for already exist as Path.resolve(). <http://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html#resolve(java.lang.String)> Now, all left to do for a chDir is: curDir = curDir.resolve(relOrAbsPath); (and maybe curDir = curDir.toRealPath();) > Apart from that, anything else I've needed can be achieved by judicious > use of the File class. At least, that's been my experience and I've > written command line Java programs that walk directory structures > examining the files and directories they find there and applying > appropriate actions. I'll need to emulate some kind of current directory, and will need to manually join user-provided relative paths (typically bare filenames) to that current directory for various uses (open,remove,rename,...). Eventually I need to spawn processes, which then need that emulated current directory to be their initial real current directory.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
A "current directory" concept for Java... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-22 16:49 +0000
Re: A "current directory" concept for Java... Jeff Higgins <jeff@invalid.invalid> - 2014-08-22 14:50 -0400
Re: A "current directory" concept for Java... Jeff Higgins <jeff@invalid.invalid> - 2014-08-22 15:10 -0400
Re: A "current directory" concept for Java... Martin Gregorie <martin@address-in-sig.invalid> - 2014-08-22 19:26 +0000
Re: A "current directory" concept for Java... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-22 23:38 +0000
Re: A "current directory" concept for Java... Martin Gregorie <martin@address-in-sig.invalid> - 2014-08-23 14:24 +0000
Re: A "current directory" concept for Java... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-23 16:31 +0000
Re: A "current directory" concept for Java... Martin Gregorie <martin@address-in-sig.invalid> - 2014-08-23 19:34 +0000
Re: A "current directory" concept for Java... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-24 08:42 +0000
Re: A "current directory" concept for Java... Martin Gregorie <martin@address-in-sig.invalid> - 2014-08-24 10:37 +0000
Re: A "current directory" concept for Java... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-24 13:41 +0000
Re: A "current directory" concept for Java... Martin Gregorie <martin@address-in-sig.invalid> - 2014-08-24 18:33 +0000
Re: A "current directory" concept for Java... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-24 22:33 +0000
Re: A "current directory" concept for Java... Martin Gregorie <martin@address-in-sig.invalid> - 2014-08-25 00:14 +0000
Re: A "current directory" concept for Java... Jeff Higgins <jeff@invalid.invalid> - 2014-08-22 19:45 -0400
Re: A "current directory" concept for Java... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-23 15:32 +0000
Re: A "current directory" concept for Java... Jeff Higgins <jeff@invalid.invalid> - 2014-08-23 12:49 -0400
Re: A "current directory" concept for Java... Jeff Higgins <jeff@invalid.invalid> - 2014-08-23 17:40 -0400
Re: A "current directory" concept for Java... Jan Burse <janburse@fastmail.fm> - 2014-08-23 10:31 +0200
With new Path (Re: A "current directory" concept for Java...) Jan Burse <janburse@fastmail.fm> - 2014-08-23 10:48 +0200
Re: With new Path (Re: A "current directory" concept for Java...) Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-23 14:38 +0000
Re: A "current directory" concept for Java... Roedy Green <see_website@mindprod.com.invalid> - 2014-08-23 05:31 -0700
csiph-web