Skip to content

Commit 56ab81c

Browse files
committed
Fix: copying between filesystems failed for non-UTF8-conformant files
1 parent 824de47 commit 56ab81c

File tree

9 files changed

+43
-4
lines changed

9 files changed

+43
-4
lines changed

src/FS-Core.package/FileSystem.class/instance/copy.toReference..st

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ copy: aPath toReference: destRef
77
[
88
inputStream := self readStreamOn: path.
99
inputStream ifNil: [ store signalFileDoesNotExist: path ].
10+
inputStream binary.
1011
destRef filesystem copyFrom: inputStream to: destRef path
1112

1213
] ensure: [ inputStream ifNotNil: [ inputStream close ]]

src/FS-Core.package/FileSystem.class/instance/copyFrom.to..st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ copyFrom: inputStream to: destPath
66
ifTrue: [ store signalFileExists: destPath ].
77
^ [
88
out := self writeStreamOn: destPath.
9-
buffer := (out isBinary ifTrue: [ByteArray] ifFalse: [String]) new: 1024.
9+
buffer := ByteArray new: 1024.
1010
[ inputStream atEnd ]
1111
whileFalse: [
1212
buffer := inputStream nextInto: buffer.

src/FS-Core.package/FileSystem.class/methodProperties.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"close" : "cwp 2/19/2011 01:39",
1313
"copy:ifAbsent:to:ifPresent:" : "CamilloBruni 1/20/2012 11:42",
1414
"copy:to:" : "cwp 4/3/2011 22:17",
15-
"copy:toReference:" : "CamilloBruni 1/20/2012 12:33",
16-
"copyFrom:to:" : "jr 2/26/2017 01:04",
15+
"copy:toReference:" : "jr 2/24/2019 20:41",
16+
"copyFrom:to:" : "CamilloBruni 1/20/2012 12:33",
1717
"createDirectory:" : "cwp 3/25/2011 13:15",
1818
"delete:" : "cwp 3/25/2011 13:14",
1919
"delimiter" : "cwp 3/25/2011 19:14",
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
tests
2+
testCopyBinary
3+
| out in contents |
4+
[
5+
out := filesystem writeStreamOn: 'gooly'.
6+
[ out binary; nextPutAll: #[16rFA 16rFB 16rFC 16rFD 16rFE 16rFD] ] ensure: [ out close ].
7+
filesystem copy: 'gooly' to: 'plonk'.
8+
in := filesystem readStreamOn: 'plonk'.
9+
contents := [ in binary; contents ] ensure: [ in close ].
10+
self assert: contents = #[16rFA 16rFB 16rFC 16rFD 16rFE 16rFD] ]
11+
ensure: [
12+
filesystem
13+
delete: 'gooly';
14+
delete: 'plonk' ]

src/FS-Tests-Core.package/FileSystemTest.class/methodProperties.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"testChangeDirectoryString" : "cwp 3/29/2011 16:34",
1313
"testChildrenAt" : "cwp 2/26/2011 18:19",
1414
"testCopy" : "lr 7/13/2010 15:19",
15+
"testCopyBinary" : "jr 2/24/2019 20:44",
1516
"testCopyDestExists" : "CamilloBruni 1/20/2012 13:23",
1617
"testCopySourceDoesntExist" : "jr 3/5/2017 13:16",
1718
"testCreateDirectoryExists" : "cwp 11/17/2009 16:56",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
SquotTrackedObjectMetadata {
22
#objectClassName : #PackageInfo,
33
#serializer : #SquotCypressCodeSerializer
44
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
tests
2+
testCopyBetweenTwoFileSystems
3+
| other bytes source target |
4+
other := self createFilesystem.
5+
source := (filesystem / 'foo') writeStream.
6+
[source nextPutAll: 'abcdef'] ensure: [source close].
7+
filesystem / 'foo' copyTo: other / 'foo'.
8+
target := (other / 'foo') readStream.
9+
bytes := [target upToEnd] ensure: [target close].
10+
self assert: 'abcdef' equals: bytes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
tests
2+
testCopyBinaryBetweenTwoFileSystems
3+
| other bytes source target |
4+
other := self createFilesystem.
5+
source := (filesystem / 'foo') writeStream.
6+
[source binary; nextPutAll: #[16rFA 16rFB 16rFC 16rFD 16rFE 16rFD]]
7+
ensure: [source close].
8+
filesystem / 'foo' copyTo: other / 'foo'.
9+
target := (other / 'foo') readStream.
10+
bytes := [target binary; upToEnd] ensure: [target close].
11+
self assert: #[16rFA 16rFB 16rFC 16rFD 16rFE 16rFD] equals: bytes.

src/FS-Tests-Memory.package/FSMemoryFilesystemTest.class/methodProperties.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44
"instance" : {
55
"createFilesystem" : "jr 3/2/2017 17:38",
66
"expectedFailures" : "jr 9/14/2016 12:51",
7+
"testCopyBetweenTwoFileSystems" : "jr 2/24/2019 20:36",
8+
"testCopyBinaryBetweenTwoFileSystems" : "jr 2/24/2019 20:37",
79
"testEqual" : "cwp 7/24/2009 00:41" } }

0 commit comments

Comments
 (0)