Elliott Hughes | 5d930ca | 2014-04-23 17:53:37 -0700 | [diff] [blame] | 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 | |
Elliott Hughes | fe77f81 | 2014-04-29 17:59:30 -0700 | [diff] [blame] | 19 | import libcore.util.Objects; |
| 20 | |
Elliott Hughes | 5d930ca | 2014-04-23 17:53:37 -0700 | [diff] [blame] | 21 | /** |
| 22 | * File information returned by fstat(2), lstat(2), and stat(2). Corresponds to C's |
| 23 | * {@code struct stat} from |
| 24 | * <a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html"><stat.h></a> |
| 25 | * |
| 26 | * @hide |
| 27 | */ |
Elliott Hughes | a2fac5b | 2014-04-28 16:59:48 -0700 | [diff] [blame] | 28 | public final class StructStat { |
| 29 | /** Device ID of device containing file. */ |
| 30 | public final long st_dev; /*dev_t*/ |
| 31 | |
| 32 | /** File serial number (inode). */ |
| 33 | public final long st_ino; /*ino_t*/ |
| 34 | |
| 35 | /** Mode (permissions) of file. */ |
| 36 | public final int st_mode; /*mode_t*/ |
| 37 | |
| 38 | /** Number of hard links to the file. */ |
| 39 | public final long st_nlink; /*nlink_t*/ |
| 40 | |
| 41 | /** User ID of file. */ |
| 42 | public final int st_uid; /*uid_t*/ |
| 43 | |
| 44 | /** Group ID of file. */ |
| 45 | public final int st_gid; /*gid_t*/ |
| 46 | |
| 47 | /** Device ID (if file is character or block special). */ |
| 48 | public final long st_rdev; /*dev_t*/ |
| 49 | |
| 50 | /** |
| 51 | * For regular files, the file size in bytes. |
| 52 | * For symbolic links, the length in bytes of the pathname contained in the symbolic link. |
| 53 | * For a shared memory object, the length in bytes. |
| 54 | * For a typed memory object, the length in bytes. |
| 55 | * For other file types, the use of this field is unspecified. |
| 56 | */ |
| 57 | public final long st_size; /*off_t*/ |
| 58 | |
| 59 | /** Time of last access. */ |
| 60 | public final long st_atime; /*time_t*/ |
| 61 | |
| 62 | /** Time of last data modification. */ |
| 63 | public final long st_mtime; /*time_t*/ |
| 64 | |
| 65 | /** Time of last status change. */ |
| 66 | public final long st_ctime; /*time_t*/ |
| 67 | |
| 68 | /** |
| 69 | * A file system-specific preferred I/O block size for this object. |
| 70 | * For some file system types, this may vary from file to file. |
| 71 | */ |
| 72 | public final long st_blksize; /*blksize_t*/ |
| 73 | |
| 74 | /** Number of blocks allocated for this object. */ |
| 75 | public final long st_blocks; /*blkcnt_t*/ |
| 76 | |
Elliott Hughes | 5d930ca | 2014-04-23 17:53:37 -0700 | [diff] [blame] | 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) { |
Elliott Hughes | a2fac5b | 2014-04-28 16:59:48 -0700 | [diff] [blame] | 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; |
Elliott Hughes | 5d930ca | 2014-04-23 17:53:37 -0700 | [diff] [blame] | 93 | } |
Elliott Hughes | fe77f81 | 2014-04-29 17:59:30 -0700 | [diff] [blame] | 94 | |
| 95 | @Override public String toString() { |
| 96 | return Objects.toString(this); |
| 97 | } |
Elliott Hughes | 5d930ca | 2014-04-23 17:53:37 -0700 | [diff] [blame] | 98 | } |