author | Jan Vrany <jan.vrany@labware.com> |
Mon, 31 Aug 2020 18:13:01 +0100 | |
branch | jv |
changeset 1115 | 12c55ec23e26 |
parent 907 | fce2e5941124 |
child 1121 | c5661215109c |
permissions | -rw-r--r-- |
109 | 1 |
"{ Package: 'stx:goodies/monticello' }" |
2 |
||
3 |
MCFileBasedRepository subclass:#MCDirectoryRepository |
|
4 |
instanceVariableNames:'directory' |
|
5 |
classVariableNames:'' |
|
6 |
poolDictionaries:'' |
|
623 | 7 |
category:'SCM-Monticello-Repositories' |
109 | 8 |
! |
9 |
||
10 |
||
228 | 11 |
!MCDirectoryRepository class methodsFor:'initialization'! |
12 |
||
13 |
new |
|
14 |
^self basicNew initialize |
|
15 |
! ! |
|
16 |
||
109 | 17 |
!MCDirectoryRepository class methodsFor:'instance creation'! |
18 |
||
228 | 19 |
directory: aStringOrFileDirectory |
20 |
||
21 |
^self new directory: aStringOrFileDirectory |
|
22 |
||
23 |
"Created: / 16-09-2010 / 14:51:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
24 |
"Modified: / 16-09-2010 / 15:59:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
25 |
! |
|
26 |
||
109 | 27 |
morphicConfigure |
228 | 28 |
| directory | |
29 |
^ (directory := UIManager default chooseDirectory) ifNotNil: |
|
30 |
[ |
|
109 | 31 |
self new directory: directory] |
32 |
! ! |
|
33 |
||
228 | 34 |
!MCDirectoryRepository class methodsFor:'as yet unclassified'! |
35 |
||
907 | 36 |
fillInTheBlankRequest |
37 |
"superclass MCRepository class says that I am responsible to implement this method" |
|
38 |
||
39 |
^ self shouldImplement |
|
40 |
! ! |
|
41 |
||
42 |
!MCDirectoryRepository class methodsFor:'queries'! |
|
43 |
||
228 | 44 |
creationTemplate |
45 |
"superclass MCRepository class says that I am responsible to implement this method" |
|
46 |
||
526 | 47 |
^ |
48 |
'MCDirectoryRepository |
|
49 |
directory: ''%1''' |
|
228 | 50 |
bindWith: (Filename currentDirectory asAbsoluteFilename / 'package-cache') asString |
51 |
||
52 |
"Modified: / 16-09-2010 / 14:53:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
526 | 53 |
"Modified: / 01-12-2011 / 20:31:31 / cg" |
228 | 54 |
! |
55 |
||
907 | 56 |
description |
57 |
^ 'directory' |
|
228 | 58 |
! ! |
59 |
||
907 | 60 |
!MCDirectoryRepository methodsFor:'accessing'! |
109 | 61 |
|
62 |
description |
|
63 |
^ directory pathName |
|
64 |
! |
|
65 |
||
66 |
directory |
|
67 |
^ directory |
|
68 |
! |
|
69 |
||
1115
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
70 |
directory: aStringOrFilename |
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
71 |
self assert: (aStringOrFilename isString or: [ aStringOrFilename isFilename ]). |
228 | 72 |
|
1115
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
73 |
directory := aStringOrFilename asFilename |
228 | 74 |
|
75 |
"Modified: / 16-09-2010 / 15:58:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1115
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
76 |
"Modified: / 25-08-2020 / 10:00:58 / Jan Vrany <jan.vrany@labware.com>" |
907 | 77 |
! ! |
109 | 78 |
|
907 | 79 |
!MCDirectoryRepository methodsFor:'as yet unclassified'! |
109 | 80 |
|
81 |
isValid |
|
82 |
^directory exists |
|
83 |
! |
|
84 |
||
228 | 85 |
literalArrayEncoding |
86 |
||
87 |
^Array |
|
88 |
with: self class name asSymbol |
|
89 |
with: #directory: |
|
528 | 90 |
with: directory pathName "directoryName" |
228 | 91 |
|
92 |
" |
|
93 |
(MCDirectoryRepository directory: '/tmp') |
|
94 |
literalArrayEncoding decodeAsLiteralArray |
|
95 |
" |
|
96 |
||
97 |
"Created: / 16-09-2010 / 16:01:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
528 | 98 |
"Modified: / 01-12-2011 / 21:01:25 / cg" |
228 | 99 |
! |
100 |
||
109 | 101 |
readStreamForFileNamed: aString do: aBlock |
1115
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
102 |
^ (directory / aString) readingFileDo: aBlock |
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
103 |
|
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
104 |
"Modified: / 25-08-2020 / 10:10:34 / Jan Vrany <jan.vrany@labware.com>" |
109 | 105 |
! |
106 |
||
107 |
writeStreamForFileNamed: aString replace: aBoolean do: aBlock |
|
1115
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
108 |
| file | |
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
109 |
|
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
110 |
file := directory / aString. |
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
111 |
(aBoolean not and: [ file exists ]) ifTrue: [ |
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
112 |
self error: ('File already exists: %1' bindWith: file pathName) |
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
113 |
]. |
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
114 |
^ file writingFileDo: aBlock |
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
115 |
|
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
116 |
"Modified: / 25-08-2020 / 10:10:39 / Jan Vrany <jan.vrany@labware.com>" |
109 | 117 |
! ! |
118 |
||
119 |
!MCDirectoryRepository methodsFor:'comparing'! |
|
120 |
||
121 |
hash |
|
122 |
^ directory pathName hash |
|
123 |
! ! |
|
124 |
||
228 | 125 |
!MCDirectoryRepository methodsFor:'displaying'! |
126 |
||
127 |
displayString |
|
128 |
||
528 | 129 |
^directory pathName "/ directoryName |
228 | 130 |
|
131 |
"Created: / 14-09-2010 / 23:18:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
528 | 132 |
"Modified: / 01-12-2011 / 21:00:33 / cg" |
228 | 133 |
! ! |
134 |
||
907 | 135 |
!MCDirectoryRepository methodsFor:'initialization'! |
136 |
||
137 |
initialize |
|
1115
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
138 |
super initialize. |
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
139 |
directory := Filename currentDirectory |
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
140 |
|
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
141 |
"Modified: / 25-08-2020 / 10:05:44 / Jan Vrany <jan.vrany@labware.com>" |
907 | 142 |
! ! |
143 |
||
144 |
!MCDirectoryRepository methodsFor:'queries'! |
|
145 |
||
146 |
allFileNames |
|
1115
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
147 |
| files | |
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
148 |
files := directory directoryContentsAsFilenames asArray. |
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
149 |
files sort: [:a :b | a modificationTime >= b modificationTime]. |
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
150 |
^ files collect: [:each | each baseName ]. |
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
151 |
|
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
152 |
"Modified: / 25-08-2020 / 10:07:29 / Jan Vrany <jan.vrany@labware.com>" |
907 | 153 |
! ! |
154 |
||
109 | 155 |
!MCDirectoryRepository class methodsFor:'documentation'! |
156 |
||
157 |
version |
|
907 | 158 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCDirectoryRepository.st,v 1.7 2014-02-12 14:53:38 cg Exp $' |
228 | 159 |
! |
160 |
||
161 |
version_CVS |
|
907 | 162 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCDirectoryRepository.st,v 1.7 2014-02-12 14:53:38 cg Exp $' |
228 | 163 |
! |
164 |
||
1115
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
165 |
version_HG |
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
166 |
|
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
167 |
^ '$Changeset: <not expanded> $' |
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
168 |
! |
12c55ec23e26
Refactor `MCDirectoryRepository` to use `Filename`
Jan Vrany <jan.vrany@labware.com>
parents:
907
diff
changeset
|
169 |
|
228 | 170 |
version_SVN |
907 | 171 |
^ '$Id: MCDirectoryRepository.st,v 1.7 2014-02-12 14:53:38 cg Exp $' |
109 | 172 |
! ! |
907 | 173 |