Filename.st
changeset 539 11aca4b770ac
parent 538 b9337c6c55bb
child 542 fec8c38962ba
--- a/Filename.st	Tue Nov 14 11:21:03 1995 +0100
+++ b/Filename.st	Tue Nov 14 11:31:39 1995 +0100
@@ -33,7 +33,7 @@
 !
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.38 1995-11-14 10:21:03 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.39 1995-11-14 10:31:39 cg Exp $'
 !
 
 documentation
@@ -1300,24 +1300,31 @@
 !
 
 copyTo:newName
-    "copy the file - the argument must be convertable to a filename"
+    "copy the file - the argument must be convertable to a filename.
+     Return true if successfull, false if not."
 
     |inStream outStream buffer bufferSize count|
 
     bufferSize := 8 * 1024.
     buffer := ByteArray new:bufferSize.
     inStream := self readStream.
+
     outStream := newName asFilename writeStream.
     (inStream isNil or:[outStream isNil]) ifTrue:[
-	^ self error:'file copy failed'
+	'FILENAME: file copy failed' errorPrintNL.
+	^ false.
     ].
 
     [inStream atEnd] whileFalse:[
 	count := inStream nextBytes:bufferSize into:buffer.
-	outStream nextPutBytes:count from:buffer.
+	(outStream nextPutBytes:count from:buffer) ~= count ifTrue:[
+	    'FILENAME: file copy failed' errorPrintNL.
+	    ^ false
+	]
     ].
     outStream close.
     inStream close.
+    ^ true
 
     "
      'Makefile' asFilename copyTo:'Makefile.foo'
@@ -1327,16 +1334,18 @@
 
 moveTo:newName
     "copy the file represented by the receiver, then delete it.
-     This is different to renaming in case of cross device moves."
+     This is different to renaming in case of cross device moves.
+     Return true if successfull, false if not."
 
-    self copyTo:newName.
-    self remove
+    (self copyTo:newName) ifFalse:[^ false].
+    ^ self remove
 !
 
 makeDirectory
-    "create a directory with the receivers name"
+    "create a directory with the receivers name.
+     Return true if successfull, false if not."
 
-    OperatingSystem createDirectory:nameString
+    ^ OperatingSystem createDirectory:nameString
 !
 
 addAccessRights:aCollection
@@ -1371,7 +1380,7 @@
     aCollection do:[:accessSymbol |
 	access := access bitAnd:(OperatingSystem accessMaskFor:accessSymbol) bitInvert.
     ].
-    OperatingSystem changeAccessModeOf:nameString to:access
+    ^ OperatingSystem changeAccessModeOf:nameString to:access
 
     "
      'foo' asFilename writeStream close.
@@ -1384,31 +1393,31 @@
 makeReadableForAll
     "make the file readable for all - you must have permission to do so."
 
-    self addAccessRights:#(readUser readGroup readOthers)
+    ^ self addAccessRights:#(readUser readGroup readOthers)
 !
 
 makeReadable
     "make the file readable for  the owner - you must have permission to do so."
 
-    self addAccessRights:#(readUser)
+    ^ self addAccessRights:#(readUser)
 !
 
 makeWritable
     "make the file writableable for all - you must have permission to do so."
 
-    self addAccessRights:#(writeUser)
+    ^ self addAccessRights:#(writeUser)
 !
 
 makeWritableForAll
     "make the file writable for all - you must have permission to do so."
 
-    self addAccessRights:#(writeUser writeGroup writeOthers)
+    ^ self addAccessRights:#(writeUser writeGroup writeOthers)
 !
 
 makeUnwritable
     "make the file unwritable for all - you must have permission to do so."
 
-    self removeAccessRights:#(writeUser writeGroup writeOthers)
+    ^ self removeAccessRights:#(writeUser writeGroup writeOthers)
 ! !
 
 !Filename methodsFor:'file utilities'!