Previous - sysFileAttribute Section Home - File System Next - sysFileDate


sysFileSetAttribute ( )

Sets the file attributes for an existing file

Usage:

sysFileSetAttribute (object me, string filePath, string attributes)

Parameters:

filePath (string) - a string specifying the file path to an existing file

attributes (string) - a string specifying the combination of file attributes to set. Only the following characters are recognized:

a - archive attribute
h - hidden attribute
r - read only attribute
s - system attribute

Returns:

(integer) - The success code

Example:

-- example shows a function that copies a file from source to destination
-- if file existed, we copy the attributes from the existing file to the new file
on fileCopy (strPathSource, strPathTarget)
  xtRose = xtra("rosetta").new()
  
  strAttributes = EMPTY
  -- checks if file already exist, if so, need to ensure that we have write privilages
  If ( xtRose.sysFileExist( strPathTarget ) = TRUE ) Then
    strAttributes = xtRose.sysFileAttribute( strPathTarget )
    If ( strAttributes contains "r" ) Then
      -- clear the read only attribute
      xtRose.sysFileSetAttribute( strPathTarget, EMPTY )
    End If
  End If
  
  -- copy the file
  xtRose.sysFileCopy( strPathSource, strPathTarget, 1)
  
  -- set back the original file attributes if there was something set
  If ( strAttributes <> EMPTY ) Then
    xtRose.sysFileSetAttribute( strPathTarget, strAttributes )
  End If
  
End

Notes:

An empty string represents that no attributes are will be set for this file.


Previous - sysFileAttribute Section Home - File System Next - sysFileDate