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

Side by Side Diff: base/sys_info_posix.cc

Issue 12212010: Truncate the download file name if it exceeds the filesystem limit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Partially addressed review comments (#3). Created 7 years, 10 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) 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/sys_info.h" 5 #include "base/sys_info.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <string.h> 8 #include <string.h>
9 #include <sys/param.h> 9 #include <sys/param.h>
10 #include <sys/utsname.h> 10 #include <sys/utsname.h>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 int64 SysInfo::AmountOfFreeDiskSpace(const FilePath& path) { 43 int64 SysInfo::AmountOfFreeDiskSpace(const FilePath& path) {
44 base::ThreadRestrictions::AssertIOAllowed(); 44 base::ThreadRestrictions::AssertIOAllowed();
45 45
46 struct statvfs stats; 46 struct statvfs stats;
47 if (statvfs(path.value().c_str(), &stats) != 0) { 47 if (statvfs(path.value().c_str(), &stats) != 0) {
48 return -1; 48 return -1;
49 } 49 }
50 return static_cast<int64>(stats.f_bavail) * stats.f_frsize; 50 return static_cast<int64>(stats.f_bavail) * stats.f_frsize;
51 } 51 }
52 52
53 // static
54 int SysInfo::GetMaximumPathComponentLength(const FilePath& path) {
55 base::ThreadRestrictions::AssertIOAllowed();
56 if (!path.IsAbsolute())
Mark Mentovai 2013/02/08 18:14:02 I don’t think this is relevant to the API. Maximum
kinaba 2013/02/12 05:51:29 Done.
57 return -1;
58
59 struct statvfs stats;
60 if (statvfs(path.value().c_str(), &stats) != 0) {
Mark Mentovai 2013/02/08 18:14:02 On Mac OS X, you need to use pathconf(…, _PC_NAME_
kinaba 2013/02/12 05:51:29 Thanks for catching it! That greatly simplifies th
61 return -1;
62 }
63 #if defined(OS_ANDROID)
64 // Android uses statfs instead of statvfs. The field name differs.
Mark Mentovai 2013/02/08 18:14:02 If you’re sticking with statfs for any code… Hide
kinaba 2013/02/12 05:51:29 Done (using pathconf).
65 return static_cast<int>(stats.f_namelen);
66 #else
67 return static_cast<int>(stats.f_namemax);
68 #endif
69 }
70
53 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) 71 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
54 // static 72 // static
55 std::string SysInfo::OperatingSystemName() { 73 std::string SysInfo::OperatingSystemName() {
56 struct utsname info; 74 struct utsname info;
57 if (uname(&info) < 0) { 75 if (uname(&info) < 0) {
58 NOTREACHED(); 76 NOTREACHED();
59 return ""; 77 return "";
60 } 78 }
61 return std::string(info.sysname); 79 return std::string(info.sysname);
62 } 80 }
(...skipping 26 matching lines...) Expand all
89 } 107 }
90 return arch; 108 return arch;
91 } 109 }
92 110
93 // static 111 // static
94 size_t SysInfo::VMAllocationGranularity() { 112 size_t SysInfo::VMAllocationGranularity() {
95 return getpagesize(); 113 return getpagesize();
96 } 114 }
97 115
98 } // namespace base 116 } // namespace base
OLDNEW
« no previous file with comments | « base/sys_info.h ('k') | base/sys_info_win.cc » ('j') | base/sys_info_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698