REXX Tips & Tricks, Version 2.80

Inf-HTML [About][Toc][Index] 0.9b (c) 1995 Peter Childs

Force the WPS to reRead the Extended Attributes

To force the WPS to reread the Extended Attributes (for example after 
changing the EA .LONGNAME) of a file you can use the following code 
(Source: Found in a public newsgroup): 

/*   */
  CALL RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs'
  CALL SysLoadFuncs

                    /* create a temporary file in the TEMP directory  */
  tempDir = value( 'TEMP',, 'OS2ENVIRONMENT' )
  tempFile = time('S')

  if right( tempDir,1 ) = '\' then
    tempFile = tempDir || tempFile
    tempFile = tempDir || '\' || tempFile

                    /* now open the folder on the WPS                 */
  call SysSetObjectData tempDir, 'OPEN=DEFAULT;'

  say 'Creating a file named "' || tempFile || '" ...'

                    /* create a temporary file                        */
  '@ECHO. This is a test file ' '>'tempFile
  say ' ... done'

  say 'Press any key after the file is shown in the folder ...'
  '@pause >NUL'

                    /* new value for the EA .LONGNAME                 */
  NewLongName = 'This is a very looong Name' || '00'x

                    /* create a valid EA                              */
  typeinfo = 'FDFF'x || d2c(length(NewLongName)) || '00'x || NewLongName

  say 'Now changing the EA .LONGNAME of the file to'
  say ' "' || newLongName ||  '" ...'
  say '(This should change the title used in the WPS!)'

                   /* change the EA                                   */
  call SysPutEA tempFile, ".LONGNAME", typeinfo
  say ' ... done'
  say 'Press any key to force the WPS to reRead the EAs'
  say '(and update the title in the folder) ...'
  '@pause >NUL'

                   /* force the WPS to reread the EAs                 */
  '@attrib -a ' tempFile '2>NUL 1>NUL'
  '@attrib +a ' tempFile '2>NUL 1>NUL'

  say 'Now the WPS should show the new title for the object.'

  say 'Press any key to delete the temporary file ...'
  '@pause >NUL'

                    /* delete the temporary file                      */
  '@DEL ' tempFile '2>NUL 1>NUL'
exit 0


Inf-HTML End Run - Successful