Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Side by Side Diff: runtime/bin/file_linux.cc

Issue 15018011: dart:io | Add FileSystemEntity.stat() and FileStat class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix Windows failures. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_LINUX) 6 #if defined(TARGET_OS_LINUX)
7 7
8 #include "bin/file.h" 8 #include "bin/file.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 195
196 off_t File::LengthFromPath(const char* name) { 196 off_t File::LengthFromPath(const char* name) {
197 struct stat st; 197 struct stat st;
198 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { 198 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) {
199 return st.st_size; 199 return st.st_size;
200 } 200 }
201 return -1; 201 return -1;
202 } 202 }
203 203
204 204
205 void File::Stat(const char* name, int64_t* data) {
206 struct stat st;
207 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) {
208 if (S_ISREG(st.st_mode)) {
209 data[kType] = kIsFile;
210 } else if (S_ISDIR(st.st_mode)) {
211 data[kType] = kIsDirectory;
212 } else if (S_ISLNK(st.st_mode)) {
213 data[kType] = kIsLink;
214 } else {
215 data[kType] = kDoesNotExist;
216 }
217 data[kCreatedTime] = st.st_ctime;
218 data[kModifiedTime] = st.st_mtime;
219 data[kAccessedTime] = st.st_atime;
220 data[kMode] = st.st_mode;
221 data[kSize] = st.st_size;
222 } else {
223 data[kType] = kDoesNotExist;
224 data[kCreatedTime] = 0;
225 data[kModifiedTime] = 0;
226 data[kAccessedTime] = 0;
227 data[kMode] = 0;
228 data[kSize] = 0;
229 }
230 }
231
232
205 time_t File::LastModified(const char* name) { 233 time_t File::LastModified(const char* name) {
206 struct stat st; 234 struct stat st;
207 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { 235 if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) {
208 return st.st_mtime; 236 return st.st_mtime;
209 } 237 }
210 return -1; 238 return -1;
211 } 239 }
212 240
213 241
214 char* File::LinkTarget(const char* pathname) { 242 char* File::LinkTarget(const char* pathname) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 return (file_1_info.st_ino == file_2_info.st_ino && 345 return (file_1_info.st_ino == file_2_info.st_ino &&
318 file_1_info.st_dev == file_2_info.st_dev) ? 346 file_1_info.st_dev == file_2_info.st_dev) ?
319 File::kIdentical : 347 File::kIdentical :
320 File::kDifferent; 348 File::kDifferent;
321 } 349 }
322 350
323 } // namespace bin 351 } // namespace bin
324 } // namespace dart 352 } // namespace dart
325 353
326 #endif // defined(TARGET_OS_LINUX) 354 #endif // defined(TARGET_OS_LINUX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698