FileOperations.st
changeset 1589 e3281d70e25c
parent 1588 6dde5ad32643
child 1590 89e229528104
equal deleted inserted replaced
1588:6dde5ad32643 1589:e3281d70e25c
     1 "{ Package: 'stx:libtool2' }"
       
     2 
       
     3 Object subclass:#FileOperations
       
     4 	instanceVariableNames:'errorString result'
       
     5 	classVariableNames:''
       
     6 	poolDictionaries:''
       
     7 	category:'Interface-Support'
       
     8 !
       
     9 
       
    10 
       
    11 !FileOperations class methodsFor:'defaults'!
       
    12 
       
    13 copyMoveIfExistSuffixString
       
    14 
       
    15     ^ '.copy'
       
    16 ! !
       
    17 
       
    18 !FileOperations methodsFor:'accessing'!
       
    19 
       
    20 errorString
       
    21     "return the value of the static variable 'ErrorString' (automatically generated)"
       
    22 
       
    23     ^ errorString
       
    24 !
       
    25 
       
    26 errorString:something
       
    27     "set the value of the static variable 'ErrorString' (automatically generated)"
       
    28 
       
    29     errorString := something.
       
    30 !
       
    31 
       
    32 result
       
    33     "return the value of the instance variable 'result' (automatically generated)"
       
    34 
       
    35     ^ result
       
    36 !
       
    37 
       
    38 result:something
       
    39     "set the value of the instance variable 'result' (automatically generated)"
       
    40 
       
    41     result := something.
       
    42 ! !
       
    43 
       
    44 !FileOperations methodsFor:'dialogs'!
       
    45 
       
    46 fileExistDialogFor:aFile
       
    47 
       
    48     ^ self fileExistDialogFor:aFile withCancel:false.
       
    49 !
       
    50 
       
    51 fileExistDialogFor:aFile withCancel:aBoolean
       
    52     | stream string|
       
    53 
       
    54     aFile exists ifTrue:[
       
    55         stream := WriteStream on:''.
       
    56         stream nextPutAll:'overwrite '.
       
    57         stream nextPutAll:(aFile asString).
       
    58         stream nextPutAll:' from '.
       
    59         (aFile modificationTime) printOn:stream format:'%(Day)-%(mon)-%(year) %h:%m:%s'.
       
    60         stream nextPutAll:' with size of '.
       
    61         stream nextPutAll:aFile fileSize asString.
       
    62         stream cr.
       
    63         stream nextPutAll:' with '.
       
    64         stream nextPutAll:aFile asString.
       
    65         stream nextPutAll:' from '.
       
    66         (aFile modificationTime) printOn:stream format:'%(Day)-%(mon)-%(year) %h:%m:%s'.
       
    67         stream nextPutAll:' with size of '.
       
    68         stream nextPutAll:aFile fileSize asString.
       
    69         string := stream contents. 
       
    70         stream close.
       
    71         aBoolean ifTrue:[
       
    72             ^ (Dialog confirmWithCancel:(string)).
       
    73         ] ifFalse:[
       
    74             ^ (Dialog confirm:(string)).
       
    75         ].
       
    76     ].
       
    77     ^ true
       
    78 ! !
       
    79 
       
    80 !FileOperations class methodsFor:'documentation'!
       
    81 
       
    82 version
       
    83     ^ '$Header$'
       
    84 ! !