@@ -14,30 +14,19 @@ var coreio = struct {
1414 Local : & localCoreFS {fs : (& core.Fs {}).New ("/" )},
1515}
1616
17- func localCoreFSErr (
18- r core.Result ,
19- ) (
20- _ error , // result
21- ) {
22- if r .OK {
23- return nil
24- }
25- if err , ok := r .Value .(error ); ok && err != nil {
26- return err
27- }
28- if r .Value != nil {
29- return core .E ("localCoreFS" , core .Sprint (r .Value ), nil )
30- }
31- return core .E ("localCoreFS" , "operation failed" , nil )
32- }
33-
3417func (l * localCoreFS ) Read (path string ) (
3518 string ,
3619 error ,
3720) {
3821 r := l .fs .Read (path )
3922 if ! r .OK {
40- return "" , localCoreFSErr (r )
23+ if err , ok := r .Value .(error ); ok && err != nil {
24+ return "" , err
25+ }
26+ if r .Value != nil {
27+ return "" , core .E ("localCoreFS" , core .Sprint (r .Value ), nil )
28+ }
29+ return "" , core .E ("localCoreFS" , "operation failed" , nil )
4130 }
4231 content , ok := r .Value .(string )
4332 if ! ok {
@@ -51,7 +40,17 @@ func (l *localCoreFS) EnsureDir(
5140) (
5241 _ error , // result
5342) {
54- return localCoreFSErr (l .fs .EnsureDir (path ))
43+ r := l .fs .EnsureDir (path )
44+ if r .OK {
45+ return nil
46+ }
47+ if err , ok := r .Value .(error ); ok && err != nil {
48+ return err
49+ }
50+ if r .Value != nil {
51+ return core .E ("localCoreFS" , core .Sprint (r .Value ), nil )
52+ }
53+ return core .E ("localCoreFS" , "operation failed" , nil )
5554}
5655
5756func (l * localCoreFS ) List (path string ) (
@@ -60,7 +59,13 @@ func (l *localCoreFS) List(path string) (
6059) {
6160 r := l .fs .List (path )
6261 if ! r .OK {
63- return nil , localCoreFSErr (r )
62+ if err , ok := r .Value .(error ); ok && err != nil {
63+ return nil , err
64+ }
65+ if r .Value != nil {
66+ return nil , core .E ("localCoreFS" , core .Sprint (r .Value ), nil )
67+ }
68+ return nil , core .E ("localCoreFS" , "operation failed" , nil )
6469 }
6570 entries , ok := r .Value .([]core.FsDirEntry )
6671 if ! ok {
@@ -78,5 +83,15 @@ func (l *localCoreFS) Delete(
7883) (
7984 _ error , // result
8085) {
81- return localCoreFSErr (l .fs .Delete (path ))
86+ r := l .fs .Delete (path )
87+ if r .OK {
88+ return nil
89+ }
90+ if err , ok := r .Value .(error ); ok && err != nil {
91+ return err
92+ }
93+ if r .Value != nil {
94+ return core .E ("localCoreFS" , core .Sprint (r .Value ), nil )
95+ }
96+ return core .E ("localCoreFS" , "operation failed" , nil )
8297}
0 commit comments