You are currently viewing the documentation for:
ECF_SetAttributes
The ECF_SetAttributes function sets the attributes of a file or a directory.
ECF_ErrorCode ECF_SetAttributes(
   const char *path,
   uint8_t attributesToSet,
   uint8_t attributesCleared
);
Parameters
path
The path of the file or directory to change attributes on.
attributesToSet
The attributes that will be set when the function returns.
ECF_ATTR_READ_ONLY:
Marks the file as read only. Note that EcFAT will currently not honour this flag when opening files.
ECF_ATTR_HIDDEN:
Marks the file as hidden.
ECF_ATTR_SYSTEM:
Marks the file as a system file.
ECF_ATTR_ARCHIVE:
Marks the file as archived.
attributesCleared
The attributes that will be cleared when the function returns.
ECF_ATTR_READ_ONLY:
Clear the ECF_ATTR_READ_ONLY flag.
ECF_ATTR_HIDDEN:
Clear the ECF_ATTR_HIDDEN flag.
ECF_ATTR_SYSTEM:
Clear the ECF_ATTR_SYSTEM flag.
ECF_ATTR_ARCHIVE:
Clear the ECF_ATTR_ARCHIVE flag.
ECF_ATTR_ALL:
Clear all user modifiable flags.
Return value
Returns one of the EcFAT error codes (ECFERR_SUCCESS on success)
Remarks
Note that if you pass arguments to both set and clear a flag it will be set. This means that you can pass 0xFF or ECF_ATTR_ALL in attributesToClear if you want to set those passed in attributesToSet and clear everything else.
Example Code

// Set the Read-only flag of file "file1.dat"
ECF_SetAttributes("A:\\file1.dat", ECF_ATTR_READ_ONLY, 0);

// Clear the Read-only flag in file2.dat 
ECF_SetAttributes("A:\\file2.dat", 0, ECF_ATTR_READ_ONLY);

// Set the Read-only flag and clear the Archive flag on directory 
ECF_SetAttributes("A:\\Dir1, ECF_ATTR_READ_ONLY, ECF_ATTR_ARCHIVE);

// Set the Read-only flag and clear all other flags on file3.dat
ECF_SetAttributes("A:\\file3.dat", ECF_ATTR_READ_ONLY, ECF_ATTR_ALL);