logo       

RE: possible 100% java implentation for chdir: msg#00040

lang.jython.devel

Subject: RE: possible 100% java implentation for chdir

Of course this requires all file system access to pass through
your CD class.  You can't do something like this:
 
cDir.cd("aDirectory")
f=open("aFile")
 
and expect to have opened aDirectory/aFile.  So open might be
able to be rewritten to use the current directory in cDir.  You
still wouldn't get the desired results with
 
cDir.cd("aDirectory")
fis=java.io.FileInputStream("aFile")
 
 
-----Original Message-----
From: Updike, Clark [mailto:Clark.Updike@xxxxxxxxxx]
Sent: Friday, January 23, 2004 12:34 PM
To: jython-dev@xxxxxxxxxxxxxxxxxxxxx
Subject: [Jython-dev] possible 100% java implentation for chdir

I realize chdir is not a high priority and there have been postings
saying that a 100% java implementation is not possible--however, I
(perhaps naively) suggest it is possible and provide source (attached). 
 
Would this be of interest to give jython a chdir?
 
 
-Clark
 
 
Sample jython session (assumes presence of dir C:\temp):
 
Jython 2.1 on java1.3.1_01 (JIT: null)
Type "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.append("C:\\temp")
>>> import CurrentDir as CD
>>> cDir = CD("C:\\temp")
>>> cDir.mkdir("aDirectory")
1
>>> cDir.cd("aDirectory")
>>> cDir.mkdir("test")
1
>>> cDir.cd("test")
>>> from java.io import File
>>> File(cDir.toFile(), "dummy.txt").createNewFile()
1
>>> cDir.list()
array(['dummy.txt'], java.lang.String)
>>> cDir.delete("dummy.txt")
1
>>> cDir.list()
array([], java.lang.String)
>>> cDir.renameTo("test_renamed")
1
>>> cDir.cd("..")
>>> cDir.list()
array(['test_renamed'], java.lang.String)
>>> cDir.delete("test_renamed")
1
>>> cDir.cd("..")
>>> cDir.delete("aDirectory")
1
>>>
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise