OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "nacl_io/node.h" | 5 #include "nacl_io/node.h" |
6 | 6 |
7 #include <assert.h> | 7 #include <assert.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <fcntl.h> | 9 #include <fcntl.h> |
10 #include <poll.h> | 10 #include <poll.h> |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 return stat_.st_mode & S_IFMT; | 193 return stat_.st_mode & S_IFMT; |
194 } | 194 } |
195 | 195 |
196 void Node::SetType(int type) { | 196 void Node::SetType(int type) { |
197 assert((type & ~S_IFMT) == 0); | 197 assert((type & ~S_IFMT) == 0); |
198 stat_.st_mode &= ~S_IFMT; | 198 stat_.st_mode &= ~S_IFMT; |
199 stat_.st_mode |= type; | 199 stat_.st_mode |= type; |
200 } | 200 } |
201 | 201 |
202 bool Node::IsaDir() { | 202 bool Node::IsaDir() { |
203 return (stat_.st_mode & S_IFDIR) != 0; | 203 return GetType() == S_IFDIR; |
204 } | 204 } |
205 | 205 |
206 bool Node::IsaFile() { | 206 bool Node::IsaFile() { |
207 return (stat_.st_mode & S_IFREG) != 0; | 207 return GetType() == S_IFREG; |
208 } | 208 } |
209 | 209 |
210 bool Node::IsaSock() { | 210 bool Node::IsaSock() { |
211 return (stat_.st_mode & S_IFSOCK) != 0; | 211 return GetType() == S_IFSOCK; |
212 } | 212 } |
213 | 213 |
214 Error Node::Isatty() { | 214 Error Node::Isatty() { |
215 return ENOTTY; | 215 return ENOTTY; |
216 } | 216 } |
217 | 217 |
218 Error Node::AddChild(const std::string& name, const ScopedNode& node) { | 218 Error Node::AddChild(const std::string& name, const ScopedNode& node) { |
219 return ENOTDIR; | 219 return ENOTDIR; |
220 } | 220 } |
221 | 221 |
(...skipping 12 matching lines...) Expand all Loading... |
234 | 234 |
235 void Node::Link() { | 235 void Node::Link() { |
236 stat_.st_nlink++; | 236 stat_.st_nlink++; |
237 } | 237 } |
238 | 238 |
239 void Node::Unlink() { | 239 void Node::Unlink() { |
240 stat_.st_nlink--; | 240 stat_.st_nlink--; |
241 } | 241 } |
242 | 242 |
243 } // namespace nacl_io | 243 } // namespace nacl_io |
OLD | NEW |