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

Side by Side Diff: base/file_util_posix.cc

Issue 7085005: Disallow links from being seen by the extensions via the fileapi. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comments incorporated. Created 9 years, 6 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
« no previous file with comments | « base/file_util.h ('k') | base/file_util_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/file_util.h" 5 #include "base/file_util.h"
6 6
7 #include <dirent.h> 7 #include <dirent.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <fnmatch.h> 10 #include <fnmatch.h>
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 // Mkdir failed, but it might have failed with EEXIST, or some other error 515 // Mkdir failed, but it might have failed with EEXIST, or some other error
516 // due to the the directory appearing out of thin air. This can occur if 516 // due to the the directory appearing out of thin air. This can occur if
517 // two processes are trying to create the same file system tree at the same 517 // two processes are trying to create the same file system tree at the same
518 // time. Check to see if it exists and make sure it is a directory. 518 // time. Check to see if it exists and make sure it is a directory.
519 if (!DirectoryExists(*i)) 519 if (!DirectoryExists(*i))
520 return false; 520 return false;
521 } 521 }
522 return true; 522 return true;
523 } 523 }
524 524
525 // TODO(rkc): Refactor GetFileInfo and FileEnumerator to handle symlinks
526 // correctly. http://code.google.com/p/chromium-os/issues/detail?id=15948
527 bool IsLink(const FilePath& file_path) {
528 struct stat st;
529 // If we can't lstat the file, it's safe to assume that the file won't at
530 // least be a 'followable' link.
531 if (lstat(file_path.value().c_str(), &st) != 0)
532 return false;
533
534 if (S_ISLNK(st.st_mode))
535 return true;
536 else
537 return false;
538 }
539
525 bool GetFileInfo(const FilePath& file_path, base::PlatformFileInfo* results) { 540 bool GetFileInfo(const FilePath& file_path, base::PlatformFileInfo* results) {
526 stat_wrapper_t file_info; 541 stat_wrapper_t file_info;
527 if (CallStat(file_path.value().c_str(), &file_info) != 0) 542 if (CallStat(file_path.value().c_str(), &file_info) != 0)
528 return false; 543 return false;
529 results->is_directory = S_ISDIR(file_info.st_mode); 544 results->is_directory = S_ISDIR(file_info.st_mode);
530 results->size = file_info.st_size; 545 results->size = file_info.st_size;
531 results->last_modified = base::Time::FromTimeT(file_info.st_mtime); 546 results->last_modified = base::Time::FromTimeT(file_info.st_mtime);
532 results->last_accessed = base::Time::FromTimeT(file_info.st_atime); 547 results->last_accessed = base::Time::FromTimeT(file_info.st_atime);
533 results->creation_time = base::Time::FromTimeT(file_info.st_ctime); 548 results->creation_time = base::Time::FromTimeT(file_info.st_ctime);
534 return true; 549 return true;
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 if (HANDLE_EINTR(close(infile)) < 0) 910 if (HANDLE_EINTR(close(infile)) < 0)
896 result = false; 911 result = false;
897 if (HANDLE_EINTR(close(outfile)) < 0) 912 if (HANDLE_EINTR(close(outfile)) < 0)
898 result = false; 913 result = false;
899 914
900 return result; 915 return result;
901 } 916 }
902 #endif // defined(OS_MACOSX) 917 #endif // defined(OS_MACOSX)
903 918
904 } // namespace file_util 919 } // namespace file_util
OLDNEW
« no previous file with comments | « base/file_util.h ('k') | base/file_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698