pharo icon indicating copy to clipboard operation
pharo copied to clipboard

AsyncFile class and AsynchFilePlugin should be fixed

Open tinchodias opened this issue 5 months ago • 3 comments

In Pharo 13, the class AsyncFile has no references and no subclasses. The primitive methods of this class mention the "AsynchFilePlugin" plugin.

In this github repo, I only have found a PR mentioning this class, that is a clean up by @astares https://github.com/pharo-project/pharo/pull/10072

The git history of the file only shows clean ups, since 2017: https://github.com/pharo-project/pharo/commits/Pharo14/src/Files/AsyncFile.class.st

The method AsyncFile>>#test:fileName: is a kind of manual test (with a script to evaluate in the comment). In MacOS, it signals an error: "PrimitiveFailed: primitive #primWriteStart:fPosition:fromBuffer:at:count: in AsyncFile failed".

test: byteCount fileName: fileName
	"AsyncFile new test: 10000 fileName: 'testData'"

	| buf1 buf2 bytesWritten bytesRead |
	buf1 := String new: byteCount withAll: $x.
	buf2 := String new: byteCount.
	self open: fileName  asFileReference fullName forWrite: true.
	self primWriteStart: fileHandle
		fPosition: 0
		fromBuffer: buf1
		at: 1
		count: byteCount.
	semaphore wait.
	bytesWritten := self primWriteResult: fileHandle.
	self close.

	self open: fileName asFileReference fullName forWrite: false.
	self primReadStart: fileHandle fPosition: 0 count: byteCount.
	semaphore wait.
	bytesRead :=
		self primReadResult: fileHandle
			intoBuffer: buf2
			at: 1
			count: byteCount.
	self close.

	buf1 = buf2 ifFalse: [self error: 'buffers do not match'].
	^ 'wrote ', bytesWritten printString, ' bytes; ',
	   'read ', bytesRead printString, ' bytes'

Pharo-13.1.0+SNAPSHOT.build.697.sha.af10a2ce70915e5076b7c9664f7851b9f7d95376

tinchodias avatar Sep 18 '25 20:09 tinchodias

Thanks martin for this issue.

Ducasse avatar Sep 22 '25 19:09 Ducasse

It seems that we still have the code in the VM:

https://github.com/pharo-project/pharo-vm/blob/a7c8a0bba9811ebeaaf5c4fd6acfef199ef8d2a9/smalltalksrc/VMMaker/AsynchFilePlugin.class.st

jecisc avatar Sep 23 '25 10:09 jecisc

For information: After discussion with Pablo, the goal would be to fix the plugin and not to remove the code. I'll update the issue title

jecisc avatar Nov 07 '25 15:11 jecisc