added another system.open; bugfix: koch clean may not break .git dirs anymore
This commit is contained in:
parent
b38c7adad1
commit
b3e24382a0
4 changed files with 15 additions and 9 deletions
2
koch.nim
2
koch.nim
|
|
@ -180,7 +180,7 @@ proc cleanAux(dir: string) =
|
||||||
of "nimcache":
|
of "nimcache":
|
||||||
echo "removing dir: ", path
|
echo "removing dir: ", path
|
||||||
removeDir(path)
|
removeDir(path)
|
||||||
of "dist", ".bzr":
|
of "dist", ".git":
|
||||||
nil
|
nil
|
||||||
else:
|
else:
|
||||||
cleanAux(path)
|
cleanAux(path)
|
||||||
|
|
|
||||||
|
|
@ -1477,9 +1477,7 @@ when not defined(EcmaScript) and not defined(NimrodVM):
|
||||||
## Opens a file named `filename` with given `mode`.
|
## Opens a file named `filename` with given `mode`.
|
||||||
##
|
##
|
||||||
## Default mode is readonly. Returns true iff the file could be opened.
|
## Default mode is readonly. Returns true iff the file could be opened.
|
||||||
## This throws no exception if the file could not be opened. The reason is
|
## This throws no exception if the file could not be opened.
|
||||||
## that the programmer needs to provide an appropriate error message
|
|
||||||
## anyway.
|
|
||||||
|
|
||||||
proc Open*(f: var TFile, filehandle: TFileHandle,
|
proc Open*(f: var TFile, filehandle: TFileHandle,
|
||||||
mode: TFileMode = fmRead): Bool
|
mode: TFileMode = fmRead): Bool
|
||||||
|
|
@ -1487,6 +1485,15 @@ when not defined(EcmaScript) and not defined(NimrodVM):
|
||||||
##
|
##
|
||||||
## Default mode is readonly. Returns true iff the file could be opened.
|
## Default mode is readonly. Returns true iff the file could be opened.
|
||||||
|
|
||||||
|
proc Open*(filename: string,
|
||||||
|
mode: TFileMode = fmRead, bufSize: int = -1): TFile =
|
||||||
|
## Opens a file named `filename` with given `mode`.
|
||||||
|
##
|
||||||
|
## Default mode is readonly. Raises an ``IO`` exception if the file
|
||||||
|
## could not be opened.
|
||||||
|
if not open(result, filename, mode, bufSize):
|
||||||
|
raise newException(EIO, "cannot open: " & filename)
|
||||||
|
|
||||||
proc reopen*(f: TFile, filename: string, mode: TFileMode = fmRead): bool
|
proc reopen*(f: TFile, filename: string, mode: TFileMode = fmRead): bool
|
||||||
## reopens the file `f` with given `filename` and `mode`. This
|
## reopens the file `f` with given `filename` and `mode`. This
|
||||||
## is often used to redirect the `stdin`, `stdout` or `stderr`
|
## is often used to redirect the `stdin`, `stdout` or `stderr`
|
||||||
|
|
@ -1582,10 +1589,7 @@ when not defined(EcmaScript) and not defined(NimrodVM):
|
||||||
iterator lines*(filename: string): string =
|
iterator lines*(filename: string): string =
|
||||||
## Iterate over any line in the file named `filename`.
|
## Iterate over any line in the file named `filename`.
|
||||||
## If the file does not exist `EIO` is raised.
|
## If the file does not exist `EIO` is raised.
|
||||||
var
|
var f = open(filename)
|
||||||
f: TFile
|
|
||||||
if not open(f, filename):
|
|
||||||
raise newException(EIO, "cannot open: " & filename)
|
|
||||||
var res = ""
|
var res = ""
|
||||||
while not endOfFile(f):
|
while not endOfFile(f):
|
||||||
rawReadLine(f, res)
|
rawReadLine(f, res)
|
||||||
|
|
|
||||||
1
todo.txt
1
todo.txt
|
|
@ -1,3 +1,4 @@
|
||||||
|
- clean up the tests!
|
||||||
- thread support: threadvar on Windows seems broken;
|
- thread support: threadvar on Windows seems broken;
|
||||||
add --deadlock_prevention:on|off switch
|
add --deadlock_prevention:on|off switch
|
||||||
- built-in serialization
|
- built-in serialization
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,8 @@ Additions
|
||||||
- The *interactive mode* (REPL) has been improved and documented for the
|
- The *interactive mode* (REPL) has been improved and documented for the
|
||||||
first time.
|
first time.
|
||||||
- Added the ``linearScanEnd``, ``unroll``, ``shallow`` pragmas.
|
- Added the ``linearScanEnd``, ``unroll``, ``shallow`` pragmas.
|
||||||
- Added ``system.reset``.
|
- Added ``system.reset`` and a version of ``system.open`` that
|
||||||
|
returns a ``TFile`` and raises an exception in case of an error.
|
||||||
- The compiler now might use a hashing for string case statements depending
|
- The compiler now might use a hashing for string case statements depending
|
||||||
on the number of string literals in the case statement.
|
on the number of string literals in the case statement.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue