Previous - sysFileSize Section Home - File System Next - sysFileSetAttribute


sysFileAttribute ( )

Obtains the file attributes for an existing file

Usage:

sysFileAttribute (object me, string filePath )

Parameters:

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

Returns:

(string) - a string specifying the combination of file attributes. The possible flags returned are:

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

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 set for this file.


Previous - sysFileSize Section Home - File System Next - sysFileSetAttribute