FAT

ctime_set()

PROTOTYPE

#include <posix.h>

int ctime_set(const char *path, const time_t *c_time);

DESCRIPTION

ctime_set() is a non-standard routine that sets the creation time of the file specified by path. Paths starting with ‘/’ are absolute. Otherwise they are relative to the CWD. c_time points to the value that becomes the file’s new creation time. Only FAT files have a creation time.

If successful, ctime_set() returns 0. Otherwise, it sets errno and returns -1.

ERROR CODES

EACCES No execute access to a directory in the path prefix.
EFAULT Either path or c_time equals NULL.
ENAMETOOLONG A name in path exceeds the effective maximum file name length.
ENOENT path is the empty string or includes a file that was not found.
ENOTDIR One of the non-leaf path components is not a directory.
EROFS The volume is read-only.

EXAMPLE

  /*-------------------------------------------------------------------*/
  /* Set creation time to Apr 10, 2008, 17:19:12.                      */
  /*-------------------------------------------------------------------*/
  ctime.tm_sec = 12;   // seconds after the minute (from 0)
  ctime.tm_min = 19;   // minutes after the hour (from 0)
  ctime.tm_hour = 17;  // hour of the day (from 0)
  ctime.tm_mday = 10;  // day of the month (from 1)
  ctime.tm_mon = 3;    // month of the year (from 0)
  ctime.tm_year = 2008 - 1900;  // years since 1900 (from 0)
  ctime.tm_isdst = -1;    // daylight saving time flag
  info.st_ctime = mktime(&ctime);
  if (ctime_set(fname, &info.st_ctime))
    error("ctime_set() failed");