97 |
97 |
98 "Created: / 23-05-2011 / 15:58:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
98 "Created: / 23-05-2011 / 15:58:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
99 ! |
99 ! |
100 |
100 |
101 readFromFile: aStringOrFilename |
101 readFromFile: aStringOrFilename |
102 |
102 ^ self readFromFile: aStringOrFilename onError:[:reason | self error:reason] |
103 | bookmarks file | |
103 ! |
|
104 |
|
105 readFromFile: aStringOrFilename onError: aBlock |
|
106 | bookmarks file pathName| |
|
107 |
104 file := aStringOrFilename asFilename. |
108 file := aStringOrFilename asFilename. |
105 file exists ifFalse: |
109 pathName := file pathName. |
106 [self error: ('File does %1 not exists' bindWith: file pathName)]. |
110 file exists ifFalse: [^ aBlock valueWithOptionalArgument:('File does %1 not exist' bindWith: pathName)]. |
107 bookmarks := self readFrom: file readStream onError: |
|
108 [self error: ('Cannot parse %1 not exists' bindWith: file pathName)]. |
|
109 bookmarks fileName: file pathName. |
|
110 ^bookmarks |
|
111 |
|
112 "Created: / 23-05-2011 / 16:10:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
113 ! |
|
114 |
|
115 readFromFile: aStringOrFilename onError: aBlock |
|
116 | bookmarks file | |
|
117 |
|
118 file := aStringOrFilename asFilename. |
|
119 file exists ifFalse: [^aBlock value]. |
|
120 bookmarks := self readFrom: file readStream onError: [^aBlock value]. |
111 bookmarks := self readFrom: file readStream onError: [^aBlock value]. |
121 bookmarks isNil ifTrue: [^aBlock value]. |
112 bookmarks isNil ifTrue: [^ aBlock valueWithOptionalArgument:('Cannot parse %1 not exist' bindWith: pathName)]. |
122 bookmarks fileName: file pathName. |
113 bookmarks fileName: pathName. |
123 ^bookmarks |
114 ^bookmarks |
124 |
115 |
125 "Created: / 23-05-2011 / 16:32:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
116 "Created: / 23-05-2011 / 16:32:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
126 "Modified: / 02-06-2011 / 19:43:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
117 "Modified: / 02-06-2011 / 19:43:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
127 "Modified: / 18-11-2011 / 14:32:24 / cg" |
118 "Modified: / 18-11-2011 / 14:32:24 / cg" |