F_chmod:
1 /*-----------------------------------------------------------------------*/ 2 /* Change Attribute */ 3 /*-----------------------------------------------------------------------*/ 4 5 FRESULT f_chmod ( 6 const TCHAR *path, /* Pointer to the file path */ 7 BYTE value, /* Attribute bits */ 8 BYTE mask /* Attribute mask to change */ 9 )10 {11 FRESULT res;12 DIR dj;13 BYTE *dir;14 DEF_NAMEBUF;15 16 17 res = chk_mounted(&path, &dj.fs, 1);18 if (res == FR_OK) {19 INIT_BUF(dj);20 res = follow_path(&dj, path); /* Follow the file path */21 FREE_BUF();22 if (_FS_RPATH && res == FR_OK && (dj.fn[NS] & NS_DOT))23 res = FR_INVALID_NAME;24 if (res == FR_OK) {25 dir = dj.dir;26 if (!dir) { /* Is it a root directory? */27 res = FR_INVALID_NAME;28 } else { /* File or sub directory */29 mask &= AM_RDO|AM_HID|AM_SYS|AM_ARC; /* Valid attribute mask */30 dir[DIR_Attr] = (value & mask) | (dir[DIR_Attr] & (BYTE)~mask); /* Apply attribute change */31 dj.fs->wflag = 1;32 res = sync(dj.fs);33 }34 }35 }36 37 LEAVE_FF(dj.fs, res);38 }
View code
Function: modifies the attributes of a file or directory.
Description:
The f_chmod function is available when _ fs_readonly = 0 and _ fs_minimize = 0.
The f_chmod function modifies the attributes of a file or directory.
F_utime:
1 /*-----------------------------------------------------------------------*/ 2 /* Change Timestamp */ 3 /*-----------------------------------------------------------------------*/ 4 5 FRESULT f_utime ( 6 const TCHAR *path, /* Pointer to the file/directory name */ 7 const FILINFO *fno /* Pointer to the time stamp to be set */ 8 ) 9 {10 FRESULT res;11 DIR dj;12 BYTE *dir;13 DEF_NAMEBUF;14 15 16 res = chk_mounted(&path, &dj.fs, 1);17 if (res == FR_OK) {18 INIT_BUF(dj);19 res = follow_path(&dj, path); /* Follow the file path */20 FREE_BUF();21 if (_FS_RPATH && res == FR_OK && (dj.fn[NS] & NS_DOT))22 res = FR_INVALID_NAME;23 if (res == FR_OK) {24 dir = dj.dir;25 if (!dir) { /* Root directory */26 res = FR_INVALID_NAME;27 } else { /* File or sub-directory */28 ST_WORD(dir+DIR_WrtTime, fno->ftime);29 ST_WORD(dir+DIR_WrtDate, fno->fdate);30 dj.fs->wflag = 1;31 res = sync(dj.fs);32 }33 }34 }35 36 LEAVE_FF(dj.fs, res);37 }
View code
Function: The f_utime function modifies the timestamp of a file or directory.
Description:
The f_utime function is available when _ fs_readonly = 0 and _ fs_minimize = 0.
The f_utime function modifies the timestamp of a file or directory (that is, the creation, modification, and access time in the file attribute ).
Example:
1 // set the read-only flag to clear the archive flag. Other flags remain unchanged. 2 f_chmod ("file.txt", ar_rdo, ar_rdo | ar_arc );
View code