[Vm-dev] VM Maker: FileAttributesPlugin.oscog-AlistairGrant.39.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Nov 29 20:38:49 UTC 2019


Eliot Miranda uploaded a new version of FileAttributesPlugin to project VM Maker:
http://source.squeak.org/VMMaker/FileAttributesPlugin.oscog-AlistairGrant.39.mcz

==================== Summary ====================

Name: FileAttributesPlugin.oscog-AlistairGrant.39
Author: AlistairGrant
Time: 4 October 2018, 8:34:34.356792 am
UUID: 986e319e-eadc-4852-853e-715149efa50e
Ancestors: FileAttributesPlugin.oscog-AlistairGrant.38

FileAttributesPlugin v2.0.1

1. The following primitives weren't updated as part of the support file restructure:

- primitiveChangeMode
- primitiveChangeOwner
- primitiveSymlinkChangeOwner
- primitiveRewinddir

Get these working again in the new framework (fapath).

2, Rewinding the directory on Windows returns the first entry.
Modify the primitive to behave this way on all platforms.

3. Path conversion primitives shouldn't include the Long Path Prefix on
Windows as part of the path.

=============== Diff against FileAttributesPlugin.oscog-AlistairGrant.38 ===============

Item was changed:
  ----- Method: FileAttributesPlugin>>primitiveChangeMode (in category 'file primitives') -----
  primitiveChangeMode
  	"Set the mode of the supplied file using chmod()."
  
+ 	| fileNameOop newMode status faPath |
- 	| fileNameOop newMode cString status |
  	<export: true>
  	<var: 'newMode' type: #'sqInt'>
+ 	<var: 'faPath' type: #'fapath *'>
- 	<var: 'cString' declareC: 'char cString[PATH_MAX+1]'>
  
  	fileNameOop := interpreterProxy stackObjectValue: 1.
  	newMode := interpreterProxy stackIntegerValue: 0.
  	(interpreterProxy failed
  		or: [(interpreterProxy isBytes: fileNameOop) not]) ifTrue:
  			[^interpreterProxy primitiveFailFor: PrimErrBadArgument].
  	self cppIf: #HAVE_CHMOD ifTrue: [
+ 		faPath := self cCode: '(fapath *) calloc(1, sizeof(fapath))'.
+ 		faPath = nil ifTrue: [^interpreterProxy primitiveFailForOSError: self cantAllocateMemory].
+ 		self faSetStPathOop: faPath _: fileNameOop.
+ 		interpreterProxy failed ifTrue: [^interpreterProxy primitiveFailureCode].
+ 
+ 		status := self chmod: (self faGetPlatPath: faPath) _: newMode.
- 		self squeakPath: fileNameOop toPlatform: cString maxLen: #PATH_MAX.
- 		interpreterProxy failed ifTrue: [^interpreterProxy primitiveFailForOSError: interpreterProxy primitiveFailureCode].
- 		status := self ch: cString mod: newMode.
  		status ~= 0 ifTrue:
  			[^interpreterProxy primitiveFailForOSError: (self cCode: 'errno')].
  		^interpreterProxy methodReturnValue: interpreterProxy nilObject.
  		].
  	^interpreterProxy primitiveFailForOSError: self unsupportedOperation.
  !

Item was changed:
  ----- Method: FileAttributesPlugin>>primitiveChangeOwner (in category 'file primitives') -----
  primitiveChangeOwner
  	"Set the owner of the supplied file using chown()."
  
+ 	| fileNameOop ownerId groupId faPath status |
- 	| fileNameOop ownerId groupId cString status |
  	<export: true>
+ 	<var: 'faPath' type: #'fapath *'>
- 	<var: 'cString' declareC: 'char cString[FA_PATH_MAX]'>
  
  	fileNameOop := interpreterProxy stackObjectValue: 2.
  	ownerId := interpreterProxy stackIntegerValue: 1.
  	groupId := interpreterProxy stackIntegerValue: 0.
  	(interpreterProxy failed
  		or: [(interpreterProxy isBytes: fileNameOop) not]) ifTrue:
  			[^interpreterProxy primitiveFailFor: PrimErrBadArgument].
  	self cppIf: #HAVE_CHOWN ifTrue: [
+ 		faPath := self cCode: '(fapath *) calloc(1, sizeof(fapath))'.
+ 		faPath = nil ifTrue: [^interpreterProxy primitiveFailForOSError: self cantAllocateMemory].
+ 		self faSetStPathOop: faPath _: fileNameOop.
+ 		interpreterProxy failed ifTrue: [^interpreterProxy primitiveFailureCode].
+ 
+ 		status := self chown: (self faGetPlatPath: faPath) _: ownerId _: groupId.
- 		self squeakPath: fileNameOop toPlatform: cString maxLen: #FA_PATH_MAX.
- 		interpreterProxy failed ifTrue: [^interpreterProxy primitiveFailForOSError: interpreterProxy primitiveFailureCode].
- 		status := self chown: cString _: ownerId _: groupId.
  		status ~= 0 ifTrue:
  			[^interpreterProxy primitiveFailForOSError: (self cCode: 'errno')].
  		^interpreterProxy methodReturnValue: interpreterProxy nilObject.
  		].
  	^interpreterProxy primitiveFailForOSError: self unsupportedOperation.
  !

Item was changed:
  ----- Method: FileAttributesPlugin>>primitiveRewinddir (in category 'file primitives') -----
  primitiveRewinddir
  	"Set directoryStream to first entry. Answer dirPointerOop."
  
+ 	| dirPointerOop faPath status resultOop |
- 	| dirPointerOop faPath |
  	<export: true>
  	<var: 'faPath' type: #'fapath *'>
  	dirPointerOop := interpreterProxy stackValue: 0.
  	faPath := self pointerFrom: dirPointerOop.
  	faPath ifNil:
  		[^interpreterProxy primitiveFailFor: PrimErrBadArgument].
+ 
+ 	status := self faRewindDirectory: faPath.
+ 	status < 0 ifTrue: [^interpreterProxy primitiveFailForOSError: status].
+ 	resultOop := self processDirectory: faPath.
+ 	interpreterProxy failed ifTrue: [^interpreterProxy primitiveFailureCode ].
+ 	^interpreterProxy methodReturnValue: resultOop.!
- 	^interpreterProxy primitiveFailForOSError: self unexpectedError.
- 	"self rewinddir: dirStream dp."
- 	"interpreterProxy pop: 2 thenPush: dirPointerOop"!

Item was changed:
  ----- Method: FileAttributesPlugin>>primitiveSymlinkChangeOwner (in category 'file primitives') -----
  primitiveSymlinkChangeOwner
  	"Set the owner of the supplied file using chown()."
  
+ 	| fileNameOop ownerId groupId faPath status |
- 	| fileNameOop ownerId groupId cString status |
  	<export: true>
+ 	<var: 'faPath' type: #'fapath *'>
- 	<var: 'cString' declareC: 'char cString[PATH_MAX+1]'>
  
  	fileNameOop := interpreterProxy stackObjectValue: 2.
  	ownerId := interpreterProxy stackIntegerValue: 1.
  	groupId := interpreterProxy stackIntegerValue: 0.
  	(interpreterProxy failed
  		or: [(interpreterProxy isBytes: fileNameOop) not]) ifTrue:
  			[^interpreterProxy primitiveFailFor: PrimErrBadArgument].
- 	self squeakPath: fileNameOop toPlatform: cString maxLen: #PATH_MAX.
- 	interpreterProxy failed ifTrue: [^interpreterProxy primitiveFailForOSError: interpreterProxy primitiveFailureCode].
  	self cppIf: #HAVE_CHOWN ifTrue: [
+ 		faPath := self cCode: '(fapath *) calloc(1, sizeof(fapath))'.
+ 		faPath = nil ifTrue: [^interpreterProxy primitiveFailForOSError: self cantAllocateMemory].
+ 		self faSetStPathOop: faPath _: fileNameOop.
+ 		interpreterProxy failed ifTrue: [^interpreterProxy primitiveFailureCode].
+ 
+ 		status := self lchown: (self faGetPlatPath: faPath) _: ownerId _: groupId.
- 		status := self lch: cString o: ownerId wn: groupId.
  		status ~= 0 ifTrue:
  			[^interpreterProxy primitiveFailForOSError: (self cCode: 'errno')].
  		^interpreterProxy methodReturnValue: interpreterProxy nilObject.
  		].
  	^interpreterProxy primitiveFailForOSError: self unsupportedOperation.
  !

Item was changed:
  ----- Method: FileAttributesPlugin>>processDirectory: (in category 'private') -----
  processDirectory: faPath
+ 	"The supplied faPath contains the full path to the current entry while iterating over a directory.
+ 	Convert the file name to an object, get the attributes and answer the resulting array."
  
  	| status entryName attributeArray resultArray |
- 
  	<var: 'faPath' type: #'fapath *'>
  
  	status := self faChar: (self faGetStFile: faPath) 
  				ToByteArray: (self addressOf: entryName put: [:val | entryName := val]).
  	status ~= 0 ifTrue:
  		[ ^interpreterProxy primitiveFailForOSError: status].
  
  	status := self fileToAttributeArray: faPath mask: 1 array: (self addressOf: attributeArray put: [:val| attributeArray := val]).
  	"If the stat() fails, still return the filename, just no attributes"
  	status ~= 0 ifTrue: [attributeArray := interpreterProxy nilObject].
  
  	"resultArray: entryName, attributeArray, dirPtrOop"
  	self remapOop: #(entryName attributeArray)
  		in: [resultArray := interpreterProxy instantiateClass: interpreterProxy classArray indexableSize: 3].
  	resultArray ifNil:
  		[^interpreterProxy primitiveFailFor: PrimErrNoMemory].
  	interpreterProxy
  		storePointer: 0 ofObject: resultArray withValue: entryName;
  		storePointer: 1 ofObject: resultArray withValue: attributeArray.
  	^resultArray!

Item was removed:
- ----- Method: FileAttributesPlugin>>squeakPath:toPlatform:maxLen: (in category 'private') -----
- squeakPath: pathOop toPlatform: cPathString maxLen: maxLength
- 	"Convert the supplied path string oop to a unix c path string.
- 	Parameter checking is done in the main primitive, so pathOop is assumed to be valid.
- 	pathOop is supplied as a precomposed UTF8 string.
- 	cPathString must be encoded using the host OS conventions, e.g. decomposed UTF8 on MacOS.
- 	Signal primitive failure on error."
- 
- 	| status uxName |
- 	<var: 'cPathString' type: 'char *'>
- 	<var: 'uxName' declareC: 'char uxName[FA_PATH_MAX]'>
- 
- 	(maxLength >= (self cCode: 'FA_PATH_MAX' inSmalltalk: [4096])) ifTrue:
- 		[^interpreterProxy primitiveFailForOSError: self invalidArguments].
- 	self cppIf: #_WIN32 ifTrue: [
- 		status := self pathOop: pathOop toBuffer: cPathString maxLen: maxLength.
- 		status ~= 0 ifTrue:
- 			[^interpreterProxy primitiveFailForOSError: status]]
- 	ifFalse: [
- 		status := self pathOop: pathOop toBuffer: uxName maxLen: #PATH_MAX.
- 		status ~= 0 ifTrue:
- 			[^interpreterProxy primitiveFailForOSError: status].
- 		status := self sq2uxPath: uxName _: (self strlen: uxName) _: cPathString _: maxLength _: 1.
- 		status = 0 ifTrue:
- 			[^interpreterProxy primitiveFailForOSError: self invalidArguments]. ].
- 	^0!

Item was changed:
  ----- Method: FileAttributesPlugin>>versionString (in category 'version string') -----
  versionString
  	"Answer a string containing the version string for this plugin."
  	<inline: #always>
+ 	^'2.0.1'!
- 	^'2.0.0'!

Item was changed:
  ----- Method: FileAttributesPlugin>>winFileTimesFor:to: (in category 'private - windows') -----
  winFileTimesFor: faPath to: attributeArray
  	<inline: #never>
  	<option: #_WIN32>
  
  	| winAttrs attributeDate status |
  	<var: 'faPath' type: #'fapath *'>
  	<var: 'attributeDate' type: #'sqLong'>
  	<var: 'winAttrs' type: #'WIN32_FILE_ATTRIBUTE_DATA'>
  
  	"Get the file attributes"
+ 	status := self cCode: 'GetFileAttributesExW(faGetPlatPath(faPath), GetFileExInfoStandard, &winAttrs)'.
- 	status := self cCode: 'GetFileAttributesExW(faGetPlatPath2(faPath), GetFileExInfoStandard, &winAttrs)'.
  	status = 0 ifTrue: [^self getAttributesFailed].
  
  	"Set the accessDate"
  	status := self winFileLastAccessTimeFor: (self addressOf: winAttrs) to: (self addressOf: attributeDate).
  	status = 0 ifFalse: [^status].
  	interpreterProxy
  		storePointer: 8
  		ofObject: attributeArray
  		withValue: (interpreterProxy signed64BitIntegerFor: attributeDate).
  
  	"Set the modifiedDate"
  	status := self winFileLastWriteTimeFor: (self addressOf: winAttrs) to: (self addressOf: attributeDate).
  	status = 0 ifFalse: [^status].
  	interpreterProxy
  		storePointer: 9
  		ofObject: attributeArray
  		withValue: (interpreterProxy signed64BitIntegerFor: attributeDate).
  
  	"Set the changeDate"
  	interpreterProxy
  		storePointer: 10
  		ofObject: attributeArray
  		withValue: interpreterProxy nilObject.
  
  	"Set the creationDate"
  	status := self winFileCreationTimeFor: (self addressOf: winAttrs) to: (self addressOf: attributeDate).
  	status = 0 ifFalse: [^status].
  	interpreterProxy
  		storePointer: 11
  		ofObject: attributeArray
  		withValue: (interpreterProxy signed64BitIntegerFor: attributeDate).
  
  	^0
  !



More information about the Vm-dev mailing list