squeak-smalltalk / squeak-filesystem Goto Github PK
View Code? Open in Web Editor NEWFileSystem is a Smalltalk API for accessing files and directories. This is an implementation for Squeak/Smalltalk.
License: Other
FileSystem is a Smalltalk API for accessing files and directories. This is an implementation for Squeak/Smalltalk.
License: Other
For interop with Monty's XMLParser package I need to add a method to String in the *fs-core-converting method category to get it to work.
Simply copy asReference and name it asFileReference
asFileReference
"Return an FSReference on disk"
^ FileSystem disk referenceTo: self
works like a charm
thanks for your hard work.
t
Expected: returns a reference of the grandparent directory.
Actual: returns a reference to the original file or directory.
ref := FileSystem disk workingDirectory / 'fstest.txt'.
ref writeStreamDo: [:stream |
stream nextPutAll: 'abcde'].
ref contents. "'abcde'"
ref writeStreamDo: [:stream |
stream nextPutAll: 'XYZ'].
ref contents "'XYZde'"
I would have expected just 'XYZ'
, analogously to FileStream class>>#forceNewFileNamed:
.
But, is this a bug or intended behavior?
This issue can be avoided by sending assureDeleted
to the reference prior to opening it for the second write. But this sounds less convenient than Squeak's built-in protocols ... And (to me) this was quite surprising and cost me a lot of time to debug. ๐
We noticed several compatibility issues that severely limit the applicability of FS in Squeak:
Different behavior of next
: In Squeak's Files package, it answers nil
when at the end of the stream. FS raises an error.
e.g., this makes it incompatible with Json:
FileSystem memory in: [:fs |
fs / 'test.txt'
writeStreamDo: [:s |
'squeak' jsonWriteOn: s];
readStreamDo: [:s |
Json readFrom: s]] "โก Error: subscript is out of bounds: 8"
No single-byte file stream option: In the Files package, StandardFileStream
reads files byte per byte as opposed to MultiByteFileStream
which uses a converter. All FSStream
s require the use of a converter. Since there seems not to be something as a null converter (?), this makes it impossible to read files that were written using StandardFileStream
.
basicBack
is missing on FSReadStream
which is sent from UTF8TextConverter
in response to #skip:
. E.g.:
FileSystem memory in: [:fs |
fs / 'test.txt'
writeStreamDo: [:s |
'squeak' jsonWriteOn: s.
s nextPut: Character null];
readStreamDo: [:s |
Json readFrom: s]] "โก MNU: #basicBack"
Does this implementation make sense?
FSReadStream>>basicBack
| result |
result := handle at: position - 1.
position := position - 1.
isBinary ifFalse: [result := result asCharacter].
^ result
No support for data get/put protocol which limits usage for Sounds and others. See hpi-swa/Squot@4b35071 for more details. /cc @MariusDoe
In general, the question remains how much compatibility is desired ... but I would like it ... :-)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.