File tree Expand file tree Collapse file tree 3 files changed +4
-15
lines changed Expand file tree Collapse file tree 3 files changed +4
-15
lines changed Original file line number Diff line number Diff line change @@ -5,9 +5,6 @@ import ./listcommon
5
5
6
6
proc listdir* [T](p: PathLike[T] = "."): PyList[T] =
7
7
result = newPyList[T]()
8
- try :
8
+ p.tryOsOp :
9
9
for i in walkDir($p, relative=true, checkDir=true):
10
10
result .append i.path
11
- except OSError as e:
12
- let oserr = e.errorCode.OSErrorCode
13
- p.raiseExcWithPath(oserr)
Original file line number Diff line number Diff line change @@ -242,13 +242,8 @@ else:
242
242
243
243
244
244
proc readlink* [T](path: PathLike[T]): T =
245
- try: result = mapPathLike[T] readlinkImpl $path
246
- except OSError as e:
247
- let errCode = e.errorCode.OSErrorCode
248
- if errCode.isNotFound:
249
- path.raiseFileNotFoundError()
250
- # XXX: may be other errors?
251
- raise
245
+ tryOsOp(path):
246
+ result = mapPathLike[T] readlinkImpl $path
252
247
253
248
when defined(windows):
254
249
proc check_dir(src_resolved: string ): bool =
Original file line number Diff line number Diff line change @@ -150,13 +150,10 @@ template scandirImpl(path){.dirty.} =
150
150
dir.closeSync
151
151
152
152
else :
153
- try :
153
+ tryOsOp(spath) :
154
154
for t in walkDir(spath, relative= true , checkDir= true ):
155
155
let de = newDirEntry[T](name = t.path, dir = spath, kind = t.kind)
156
156
yield de
157
- except OSError as e:
158
- let oserr = e.errorCode.OSErrorCode
159
- path.raiseExcWithPath(oserr)
160
157
161
158
iterator scandir*[T](path: PathLike[T]): DirEntry[T] = scandirImpl path
162
159
iterator scandirIter*[T](path: T): DirEntry[T]{.closure.} =
You can’t perform that action at this time.
0 commit comments