1/********************************************************************
2 * Copyright (c) 2013 - 2014, Pivotal Inc.
3 * All rights reserved.
4 *
5 * Author: Zhanwei Wang
6 ********************************************************************/
7/********************************************************************
8 * 2014 -
9 * open source under Apache License Version 2.0
10 ********************************************************************/
11/**
12 * Licensed to the Apache Software Foundation (ASF) under one
13 * or more contributor license agreements. See the NOTICE file
14 * distributed with this work for additional information
15 * regarding copyright ownership. The ASF licenses this file
16 * to you under the Apache License, Version 2.0 (the
17 * "License"); you may not use this file except in compliance
18 * with the License. You may obtain a copy of the License at
19 *
20 * http://www.apache.org/licenses/LICENSE-2.0
21 *
22 * Unless required by applicable law or agreed to in writing, software
23 * distributed under the License is distributed on an "AS IS" BASIS,
24 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 * See the License for the specific language governing permissions and
26 * limitations under the License.
27 */
28#ifndef _HDFS_LIBHDFS3_CLIENT_FILESTATUS_H_
29#define _HDFS_LIBHDFS3_CLIENT_FILESTATUS_H_
30
31#include "Permission.h"
32
33#include <string>
34
35namespace Hdfs {
36
37class FileStatus {
38public:
39 FileStatus() :
40 isdir(false), atime(0), blocksize(0), length(0), mtime(
41 0), permission(0644), replications(0) {
42 }
43
44 int64_t getAccessTime() const {
45 return atime;
46 }
47
48 void setAccessTime(int64_t accessTime) {
49 atime = accessTime;
50 }
51
52 short getReplication() const {
53 return replications;
54 }
55
56 void setReplication(short blockReplication) {
57 replications = blockReplication;
58 }
59
60 int64_t getBlockSize() const {
61 return blocksize;
62 }
63
64 void setBlocksize(int64_t blocksize) {
65 this->blocksize = blocksize;
66 }
67
68 const char * getGroup() const {
69 return group.c_str();
70 }
71
72 void setGroup(const char * group) {
73 this->group = group;
74 }
75
76 /**
77 * Is this a directory?
78 * @return true if this is a directory
79 */
80 bool isDirectory() const {
81 return isdir;
82 }
83
84 void setIsdir(bool isdir) {
85 this->isdir = isdir;
86 }
87
88 int64_t getLength() const {
89 return length;
90 }
91
92 void setLength(int64_t length) {
93 this->length = length;
94 }
95
96 int64_t getModificationTime() const {
97 return mtime;
98 }
99
100 void setModificationTime(int64_t modificationTime) {
101 mtime = modificationTime;
102 }
103
104 const char * getOwner() const {
105 return owner.c_str();
106 }
107
108 void setOwner(const char * owner) {
109 this->owner = owner;
110 }
111
112 const char * getPath() const {
113 return path.c_str();
114 }
115
116 void setPath(const char * path) {
117 this->path = path;
118 }
119
120 const Permission & getPermission() const {
121 return permission;
122 }
123
124 void setPermission(const Permission & permission) {
125 this->permission = permission;
126 }
127
128 const char * getSymlink() const {
129 return symlink.c_str();
130 }
131
132 void setSymlink(const char * symlink) {
133 this->symlink = symlink;
134 }
135
136 /**
137 * Is this a file?
138 * @return true if this is a file
139 */
140 bool isFile() {
141 return !isdir && !isSymlink();
142 }
143
144 /**
145 * Is this a symbolic link?
146 * @return true if this is a symbolic link
147 */
148 bool isSymlink() {
149 return !symlink.empty();
150 }
151
152private:
153 bool isdir;
154 int64_t atime;
155 int64_t blocksize;
156 int64_t length;
157 int64_t mtime;
158 Permission permission;
159 short replications;
160 std::string group;
161 std::string owner;
162 std::string path;
163 std::string symlink;
164};
165
166}
167#endif
168