Start of changelstat64_time64()--Get File or Link Information (large file and time64_t enabled)


  Syntax
 #include <sys/stat.h>

 int lstat64_time64(const char *path, struct stat64_time64 *buf);  
  Service Program Name: QP0LLIB1

  Default Public Authority: *USE

  Threadsafe: Conditional; see Usage Notes for lstat().

The lstat64_time64() function gets status information about a specified file and places it in the area of memory pointed to by buf. If the named file is a symbolic link, lstat64_time64() returns information about the symbolic link itself.

The information is returned in the stat64_time64 structure, referred to by buf. For details on the stat64_time64 structure, see stat64_time64()--Get File Information (large file and time64_t enabled).

If the named file is not a symbolic link, lstat64_time64() updates the time-related fields before putting information in the stat64_time64 structure.

For additional information about parameters, authorities required, and error conditions, see lstat()--Get File or Link Information.

See QlgLstat64_time64()--Get File or Link Information (large file and time64_t enabled) for a description and an example of supplying the path in any CCSID.


Usage Notes

  1. When you develop in C-based languages, the prototypes for the 64-bit APIs are normally hidden. To use the lstat64_time64() API and the struct stat64_time64 data type, you must compile the source with the _LARGE_FILE_API defined.

  2. While the st_atime, st_mtime, and st_ctime fields are time64_t fields, the API will not return time values beyond what can be contained in a time_t field.

  3. All of the usage notes for lstat() apply to lstat64_time64(). See Usage Notes in the lstat() API.

Example

The following example provides status information for a file.

Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.

#define _LARGE_FILE_API
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <time.h>
#include <stdio.h>

main() {
  char fn[]="temp.file", ln[]="temp.link";
  struct stat64_time64 info;
  int file_descriptor;

  if ((file_descriptor = creat64(fn, S_IWUSR)) < 0)
    perror("creat64() error");
  else {
    close(file_descriptor);
    if (link(fn, ln) != 0)
      perror("link() error");
    else {
      if (lstat64_time64(ln, &info) != 0)
        perror("lstat64_time64() error");
      else {
        puts("lstat64_time64() returned:");
        printf("  inode:   %d\n",   (int) info.st_ino);
        printf(" dev id:   %d\n",   (int) info.st_dev);
        printf("   mode:   %08x\n",       info.st_mode);
        printf("  links:   %d\n",         info.st_nlink);
        printf("    uid:   %d\n",   (int) info.st_uid);
        printf("    gid:   %d\n",   (int) info.st_gid);
        printf("   size:   %lld\n", (long long) info.st_size);
      }
      unlink(ln);
    }
    unlink(fn);
  }
}

Output:

lstat64_time64() returned:
  inode:   3022
 dev id:   1
   mode:   00008080
  links:   2
    uid:   137
    gid:   500
   size:   18

End of change
API introduced: IBM® i 7.2

[ Back to top | UNIX-Type APIs | APIs by category ]