1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.system; 18 19 import libcore.util.Objects; 20 21 /** 22 * File information returned by {@link Os#fstat}, {@link Os#lstat}, and {@link Os#stat}. 23 * Corresponds to C's {@code struct stat} from {@code <stat.h>}. 24 */ 25 public final class StructStat { 26 /** Device ID of device containing file. */ 27 public final long st_dev; /*dev_t*/ 28 29 /** File serial number (inode). */ 30 public final long st_ino; /*ino_t*/ 31 32 /** Mode (permissions) of file. */ 33 public final int st_mode; /*mode_t*/ 34 35 /** Number of hard links to the file. */ 36 public final long st_nlink; /*nlink_t*/ 37 38 /** User ID of file. */ 39 public final int st_uid; /*uid_t*/ 40 41 /** Group ID of file. */ 42 public final int st_gid; /*gid_t*/ 43 44 /** Device ID (if file is character or block special). */ 45 public final long st_rdev; /*dev_t*/ 46 47 /** 48 * For regular files, the file size in bytes. 49 * For symbolic links, the length in bytes of the pathname contained in the symbolic link. 50 * For a shared memory object, the length in bytes. 51 * For a typed memory object, the length in bytes. 52 * For other file types, the use of this field is unspecified. 53 */ 54 public final long st_size; /*off_t*/ 55 56 /** Time of last access. */ 57 public final long st_atime; /*time_t*/ 58 59 /** Time of last data modification. */ 60 public final long st_mtime; /*time_t*/ 61 62 /** Time of last status change. */ 63 public final long st_ctime; /*time_t*/ 64 65 /** 66 * A file system-specific preferred I/O block size for this object. 67 * For some file system types, this may vary from file to file. 68 */ 69 public final long st_blksize; /*blksize_t*/ 70 71 /** Number of blocks allocated for this object. */ 72 public final long st_blocks; /*blkcnt_t*/ 73 74 /** 75 * Constructs an instance with the given field values. 76 */ 77 public StructStat(long st_dev, long st_ino, int st_mode, long st_nlink, int st_uid, int st_gid, 78 long st_rdev, long st_size, long st_atime, long st_mtime, long st_ctime, 79 long st_blksize, long st_blocks) { 80 this.st_dev = st_dev; 81 this.st_ino = st_ino; 82 this.st_mode = st_mode; 83 this.st_nlink = st_nlink; 84 this.st_uid = st_uid; 85 this.st_gid = st_gid; 86 this.st_rdev = st_rdev; 87 this.st_size = st_size; 88 this.st_atime = st_atime; 89 this.st_mtime = st_mtime; 90 this.st_ctime = st_ctime; 91 this.st_blksize = st_blksize; 92 this.st_blocks = st_blocks; 93 } 94 95 @Override public String toString() { 96 return Objects.toString(this); 97 } 98 } 99