BookmarkList.st
changeset 14810 2e3231bb0b9e
parent 13855 98731325dba3
child 14811 1105a50bafa5
equal deleted inserted replaced
14809:9025aeaf760f 14810:2e3231bb0b9e
    83 
    83 
    84     "Modified: / 23-05-2011 / 13:57:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    84     "Modified: / 23-05-2011 / 13:57:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    85 !
    85 !
    86 
    86 
    87 readFrom: aStream onError: aBlock
    87 readFrom: aStream onError: aBlock
    88 
       
    89     | litArray |
    88     | litArray |
       
    89 
    90     ^[
    90     ^[
    91         litArray := Compiler evaluate: aStream contents asString.
    91         litArray := Compiler evaluate: aStream contents asString.
    92         litArray decodeAsLiteralArray.
    92         litArray decodeAsLiteralArray.
    93     ] on: Error do: [
    93     ] on: Error do: [
    94         aBlock value.
    94         aBlock value.
    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"
   404 ! !
   395 ! !
   405 
   396 
   406 !BookmarkList class methodsFor:'documentation'!
   397 !BookmarkList class methodsFor:'documentation'!
   407 
   398 
   408 version_CVS
   399 version_CVS
   409     ^ '$Header: /cvs/stx/stx/libtool/BookmarkList.st,v 1.7 2014-02-05 18:59:48 cg Exp $'
   400     ^ '$Header: /cvs/stx/stx/libtool/BookmarkList.st,v 1.8 2014-11-04 11:13:55 cg Exp $'
   410 !
   401 !
   411 
   402 
   412 version_SVN
   403 version_SVN
   413     ^ '$Id: BookmarkList.st,v 1.7 2014-02-05 18:59:48 cg Exp $'
   404     ^ '$Id: BookmarkList.st,v 1.8 2014-11-04 11:13:55 cg Exp $'
   414 ! !
   405 ! !
   415 
   406