StructStat.java revision 34721e8e0051258e87848bae25baf50722b4c76a
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 17package android.system; 18 19import 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 * @hide 26 */ 27public final class StructStat { 28 /** Device ID of device containing file. */ 29 public final long st_dev; /*dev_t*/ 30 31 /** File serial number (inode). */ 32 public final long st_ino; /*ino_t*/ 33 34 /** Mode (permissions) of file. */ 35 public final int st_mode; /*mode_t*/ 36 37 /** Number of hard links to the file. */ 38 public final long st_nlink; /*nlink_t*/ 39 40 /** User ID of file. */ 41 public final int st_uid; /*uid_t*/ 42 43 /** Group ID of file. */ 44 public final int st_gid; /*gid_t*/ 45 46 /** Device ID (if file is character or block special). */ 47 public final long st_rdev; /*dev_t*/ 48 49 /** 50 * For regular files, the file size in bytes. 51 * For symbolic links, the length in bytes of the pathname contained in the symbolic link. 52 * For a shared memory object, the length in bytes. 53 * For a typed memory object, the length in bytes. 54 * For other file types, the use of this field is unspecified. 55 */ 56 public final long st_size; /*off_t*/ 57 58 /** Time of last access. */ 59 public final long st_atime; /*time_t*/ 60 61 /** Time of last data modification. */ 62 public final long st_mtime; /*time_t*/ 63 64 /** Time of last status change. */ 65 public final long st_ctime; /*time_t*/ 66 67 /** 68 * A file system-specific preferred I/O block size for this object. 69 * For some file system types, this may vary from file to file. 70 */ 71 public final long st_blksize; /*blksize_t*/ 72 73 /** Number of blocks allocated for this object. */ 74 public final long st_blocks; /*blkcnt_t*/ 75 76 /** 77 * Constructs an instance with the given field values. 78 */ 79 public StructStat(long st_dev, long st_ino, int st_mode, long st_nlink, int st_uid, int st_gid, 80 long st_rdev, long st_size, long st_atime, long st_mtime, long st_ctime, 81 long st_blksize, long st_blocks) { 82 this.st_dev = st_dev; 83 this.st_ino = st_ino; 84 this.st_mode = st_mode; 85 this.st_nlink = st_nlink; 86 this.st_uid = st_uid; 87 this.st_gid = st_gid; 88 this.st_rdev = st_rdev; 89 this.st_size = st_size; 90 this.st_atime = st_atime; 91 this.st_mtime = st_mtime; 92 this.st_ctime = st_ctime; 93 this.st_blksize = st_blksize; 94 this.st_blocks = st_blocks; 95 } 96 97 @Override public String toString() { 98 return Objects.toString(this); 99 } 100} 101