[Nice-commit] Nice/stdlib/nice/io file.nice,1.1,1.2
Brought to you by:
bonniot
|
From: Daniel B. <bo...@us...> - 2005-03-04 09:48:59
|
Update of /cvsroot/nice/Nice/stdlib/nice/io In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8992/stdlib/nice/io Modified Files: file.nice Log Message: Fixed some errors in nice.io and end-of-line weirdnesses. Still disable its compilation since some errors remain. Index: file.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/io/file.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** file.nice 3 Mar 2005 23:50:04 -0000 1.1 --- file.nice 4 Mar 2005 09:48:16 -0000 1.2 *************** *** 101,114 **** */ String read(File file, ?String encoding = null) ! requires file.exists(): "File " file " does not exist", ! file.isFile(): file + " is not a normal file. Only normal files can be read." { let chars = new char[blockSize]; let buff = new StringBuffer(); ! let input = new BufferedReader( (encoding == null) ? new java.io.FileReader(file) : new java.io.InputStreamReader( ! new java.io.FileInputStream(file), encoding) ); using(input) { --- 101,114 ---- */ String read(File file, ?String encoding = null) ! requires file.exists(): "File " file " does not exist", ! file.isFile(): file + " is not a normal file. Only normal files can be read." { let chars = new char[blockSize]; let buff = new StringBuffer(); ! let input = new java.io.BufferedReader( (encoding == null) ? new java.io.FileReader(file) : new java.io.InputStreamReader( ! new java.io.FileInputStream(file), encoding) ); using(input) { *************** *** 118,150 **** } return buff.toString(); ! } ! ! /** ! * Opens a file and returns a generator which yields the lines contained in the file, ! * one by one. ! */ ! void->String readLines(File file, ?encoding = null) ! requires file.exists(): "File " file " does not exist", ! file.isFile(): file + " is not a normal file. Only normal files can be read." ! { ! let input = new BufferedReader( (encoding == null) ? new java.io.FileReader(file) : new java.io.InputStreamReader( ! new java.io.FileInputStream(file), encoding) ! ); ! void close() { input.close(); stop(); } ! return ()=> try { ! return input.readLine() || close(); ! } catch (Throwable t) { ! input.close(); ! throw t; } } ! ! /** ! * Returns the standard temp directory. */ ! File getTempDir() { //There must be a better way? let f = createTempFile("getTempDir", "test"); --- 118,152 ---- } return buff.toString(); ! } ! ! /** ! * Opens a file and returns a generator which yields the lines contained in the file, ! * one by one. ! */ ! void->String readLines(File file, ?String encoding = null) ! requires file.exists(): "File " file " does not exist", ! file.isFile(): file + " is not a normal file. Only normal files can be read." ! { ! let input = new java.io.BufferedReader( (encoding == null) ? new java.io.FileReader(file) : new java.io.InputStreamReader( ! new java.io.FileInputStream(file), encoding) ! ); ! void close() { input.close(); stop(); } ! return ()=> { ! try { ! return input.readLine() || close(); ! } catch (Throwable t) { ! input.close(); ! throw t; } + }; } ! ! /** ! * Returns the standard temp directory. */ ! File getTempDir() { //There must be a better way? let f = createTempFile("getTempDir", "test"); |