Skip to content

Commit

Permalink
dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-krivanek committed Jul 9, 2019
1 parent 911270f commit 23e6c2e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/Files/File.class.st
Expand Up @@ -1093,9 +1093,7 @@ File >> basename [
File >> basicOpenForWrite: writeMode [
"Open the file with the given name. If writeMode is true, allow writing, otherwise open the file in read-only mode."

(writeMode and: [ FileSystem disk isWritable not ]) ifTrue: [
(ReadOnlyFileException new
messageText: 'Attempt to open file ' , name, ' as writable on a read-only file system') signal].
writeMode ifTrue: [ self checkWritableFilesystem ].

^ self class
retryWithGC: [ self class open: name utf8Encoded writable: writeMode ]
Expand All @@ -1117,6 +1115,20 @@ File >> checkDoesNotExist [
^ FileAlreadyExistsException signalOnFile: self ]
]

{ #category : #private }
File >> checkWritableFilesystem [

"We need to check if the image is in the read-only mode. While this is a responsibility of
the disk FileSystem that may not be installed in the image, we need to do an ugly workaround
using #canUnderstand"

((FileSystem canUnderstand: #disk) and: [ FileSystem disk isWritable not ]) ifTrue: [
(ReadOnlyFileException new
messageText: 'Attempt to open file ' , name, ' as writable on a read-only file system') signal].


]

{ #category : #'open/close' }
File >> delete [
"Delete the receiver"
Expand Down

0 comments on commit 23e6c2e

Please sign in to comment.