1 "{ Package: 'stx:libtool2' }" |
|
2 |
|
3 FileOperations subclass:#Create |
|
4 instanceVariableNames:'' |
|
5 classVariableNames:'' |
|
6 poolDictionaries:'' |
|
7 category:'Interface-Support' |
|
8 ! |
|
9 |
|
10 |
|
11 !Create class methodsFor:'actions'! |
|
12 |
|
13 createDirectory:newName |
|
14 |
|
15 |instance| |
|
16 |
|
17 instance := self new. |
|
18 instance createDirectory:newName. |
|
19 ^ instance |
|
20 ! |
|
21 |
|
22 createFile:newName |
|
23 |
|
24 |instance| |
|
25 |
|
26 instance := self new. |
|
27 instance createFile:newName. |
|
28 ^ instance |
|
29 ! ! |
|
30 |
|
31 !Create methodsFor:'actions'! |
|
32 |
|
33 createDirectory:newName |
|
34 |msg| |
|
35 |
|
36 newName exists ifTrue:[ |
|
37 DialogBox warn:(newName, ' already exists.'). |
|
38 result := false. |
|
39 ^ self |
|
40 ]. |
|
41 |
|
42 newName makeDirectory ifFalse:[ |
|
43 msg := errorString := ('cannot create directory '', newName,'' !!') , '\\(' , (OperatingSystem lastErrorString) , ')'. |
|
44 errorString := msg withCRs. |
|
45 DialogBox warn:errorString. |
|
46 result := false. |
|
47 ^ self |
|
48 ]. |
|
49 result := true. |
|
50 ! |
|
51 |
|
52 createFile:file |
|
53 "create an empty file" |
|
54 |
|
55 |aStream newName msg| |
|
56 |
|
57 newName := file baseName. |
|
58 file exists ifTrue:[ |
|
59 (Dialog |
|
60 confirm:(newName, ' already exists\\truncate ?') withCRs |
|
61 yesLabel:('Truncate') |
|
62 noLabel:('Cancel')) |
|
63 ifFalse:[^ self]. |
|
64 ]. |
|
65 |
|
66 FileStream openErrorSignal handle:[:ex| |
|
67 msg := ('Cannot create file '', newName,'' !!') , '\\(' , (FileStream lastErrorString) , ')'. |
|
68 errorString := msg withCRs. |
|
69 ^ DialogBox warn:errorString |
|
70 ] do:[ |
|
71 aStream := file newReadWriteStream. |
|
72 ]. |
|
73 aStream notNil ifTrue:[ |
|
74 aStream close. |
|
75 ] ifFalse:[ |
|
76 msg := ('Cannot create file '', newName, '' !!') , '\\(' , (FileStream lastErrorString) , ')'. |
|
77 errorString := msg withCRs. |
|
78 ^ DialogBox warn:errorString |
|
79 ]. |
|
80 ! ! |
|
81 |
|
82 !Create class methodsFor:'documentation'! |
|
83 |
|
84 version |
|
85 ^ '$Header$' |
|
86 ! ! |
|