2883 ^ self contentsSpecies == ByteArray |
2884 ^ self contentsSpecies == ByteArray |
2884 |
2885 |
2885 "Modified: 15.5.1996 / 17:53:51 / cg" |
2886 "Modified: 15.5.1996 / 17:53:51 / cg" |
2886 ! |
2887 ! |
2887 |
2888 |
|
2889 isContentsEqualTo:aStringOrByteArray |
|
2890 "answer true, if the contents of myself from the current position |
|
2891 to the end is equal to aStringOrByteArray. |
|
2892 |
|
2893 Avoid allocating of lots of memory when comparing large files." |
|
2894 |
|
2895 |collectionSize bufferSize buffer nRead offset| |
|
2896 |
|
2897 collectionSize := aStringOrByteArray size. |
|
2898 |
|
2899 bufferSize := 4096 min:collectionSize. |
|
2900 buffer := aStringOrByteArray species new:bufferSize. |
|
2901 offset := 1. |
|
2902 |
|
2903 [collectionSize ~~ 0] whileTrue:[ |
|
2904 nRead := self nextAvailable:(bufferSize min:collectionSize) into:buffer startingAt:1. |
|
2905 (aStringOrByteArray sameContentsFrom:offset to:offset+nRead-1 as:buffer startingAt:1) ifFalse:[ |
|
2906 ^ false. |
|
2907 ]. |
|
2908 collectionSize := collectionSize - nRead. |
|
2909 offset := offset + nRead. |
|
2910 ]. |
|
2911 |
|
2912 ^ self atEnd. |
|
2913 |
|
2914 " |
|
2915 |string| |
|
2916 |
|
2917 string := '123456789abcdefghijklmnopqrstuvwxyz'. |
|
2918 string readStream isContentsEqualTo:string. |
|
2919 |
|
2920 string := '123456789abcdefghijklmnopqrstuvwxyz'. |
|
2921 string readStream isContentsEqualTo:'Z', string. |
|
2922 |
|
2923 |string| |
|
2924 |
|
2925 string := '/etc/hosts' asFilename contentsOfEntireFile. |
|
2926 '/etc/hosts' asFilename readStream isContentsEqualTo:string. |
|
2927 " |
|
2928 |
|
2929 "Created: / 18-11-2019 / 15:24:43 / Stefan Vogel" |
|
2930 ! |
|
2931 |
2888 isOpen |
2932 isOpen |
2889 "for compatibility with externalStream: |
2933 "for compatibility with externalStream: |
2890 return true, if this stream is open." |
2934 return true, if this stream is open." |
2891 |
2935 |
2892 ^ true |
2936 ^ true |