wsscripts
Workspace Scripts
System loadedApplications select: [:each | each name = #Chronos]. self subApplications do: [:sa | sa defined do: [:each | each comment notEmpty ifTrue: [Transcript show: each name;cr. Transcript show:each **comment**;cr. Transcript show: '++++++++++++';cr ]]]
Print Numbers
| stream number | number := self testResult timeOfTestsIn: aTest. stream := WriteStream on: (String new: 20). Locale current lcNumeric printNumber: number on: stream. ^stream contents
ByteArray»asHexString
"Answer a copy of the receiver as a String."
| string |
string := String new. self do: [:each | string := string , (each abtHexPaddedTo: 2) , ' ']. ^string
Change File Time
CfsDirectoryDescriptor>>changeTime: path to: stCtime | func dd handle accessTime modifiedTime creationTime rtn ctime | func := PlatformFunction callingConvention: 'c' function: 'SetFileTime' library: 'kernel32.dll' parameterTypes: #(pointer pointer pointer pointer) returnType: #int32. handle := self createFile: path. " (dd := CfsDirectoryDescriptor opendir: path pattern: '*' mode: FREG | FDIR) isCfsError ifTrue: [^self error: dd message]. handle := dd firstEntry." ctime := (DateAndTime date: stCtime first time: stCtime last) asNanoseconds. ctime := ByteArray fromLargeInteger: ctime. modifiedTime := creationTime := CfsOSFiletime new dwHighDateTime: (ctime uint32At: 1); dwLowDateTime: (ctime uint32At: 4); yourself. accessTime := CfsOSFiletime new dwHighDateTime: 0; dwLowDateTime: 0; yourself. " modifiedTime := CfsOSFiletime new dwHighDateTime: 0; dwLowDateTime: 0; yourself." rtn := func callWith: handle with: creationTime with: accessTime with: modifiedTime.
CfsDirectoryDescriptor>>createFile: path | func access share security creation flags templateFile rtn | func := PlatformFunction callingConvention: 'c' function: 'CreateFileA' library: 'kernel32.dll' parameterTypes: #(pointer uint32 uint32 pointer uint32 uint32 pointer) returnType: #int32. access := 2. share := 0. security := nil. creation := 3. flags := 0. templateFile := 0. rtn := func callWith: path with: access with: share with: security with: creation with: flags with: templateFile. rtn = 0 ifFalse: [self halt. CfsFileDescriptor getLastError]. ^rtn
| collection dd de name new maxYear| "There is NO WAY to change directory creation time via code. Set the date and do a copy" "This works on files" name := 'C:\Program Files (x86)\JAS\_jvm\bin'. name := 'C:\temp\xyzzy'. collection := OrderedCollection new. maxYear := 2010. (dd := CfsDirectoryDescriptor opendir: name pattern: '*' mode: FREG | FDIR) isCfsError ifTrue: [^self error: dd message]. [(de := dd readdir) notNil] whileTrue: [collection add: de]. new := collection select: [:each | each stCtime first year > maxYear or:[each stMtime first year > maxYear ]]. Transcript show: 'Before ++++++++++++++++++++++++++++++';cr. new do: [:each ||type| type := each isDir ifTrue: ['dir'] ifFalse: ['file'].Transcript show: type, ' ', each dName, ' A->', each stAtime printString, ' C->', each stCtime printString, ' M->', each stMtime printString;cr]. new do: [:each ||type path | path := name, '\', each dName. each isDir ifTrue: [each stCtime first year: maxYear. CfsDirectoryDescriptor changeTime: path to: each stCtime] ifFalse: [each stMtime first year: maxYear. CfsFileDescriptor touch: path time: each stMtime]]. Transcript show: 'After ++++++++++++++++++++++++++++++';cr. new do: [:each | Transcript show: each dName, ' A->', each stAtime printString, ' C->', each stCtime printString, ' M->', each stMtime printString;cr]. dd closedir.
wsscripts.txt · Last modified: 2019/07/28 10:19 by 127.0.0.1