| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/base/util.h" | 5 #include "remoting/base/util.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 } | 315 } |
| 316 | 316 |
| 317 return true; | 317 return true; |
| 318 } | 318 } |
| 319 | 319 |
| 320 std::string GetUsername() { | 320 std::string GetUsername() { |
| 321 #if defined(OS_POSIX) | 321 #if defined(OS_POSIX) |
| 322 long buf_size = sysconf(_SC_GETPW_R_SIZE_MAX); | 322 long buf_size = sysconf(_SC_GETPW_R_SIZE_MAX); |
| 323 if (buf_size <= 0) | 323 if (buf_size <= 0) |
| 324 return std::string(); | 324 return std::string(); |
| 325 scoped_array<char> buf(new char[buf_size]); | 325 scoped_ptr<char[]> buf(new char[buf_size]); |
| 326 struct passwd passwd; | 326 struct passwd passwd; |
| 327 struct passwd* passwd_result = NULL; | 327 struct passwd* passwd_result = NULL; |
| 328 getpwuid_r(getuid(), &passwd, buf.get(), buf_size, &passwd_result); | 328 getpwuid_r(getuid(), &passwd, buf.get(), buf_size, &passwd_result); |
| 329 if (!passwd_result) | 329 if (!passwd_result) |
| 330 return std::string(); | 330 return std::string(); |
| 331 return std::string(passwd_result->pw_name); | 331 return std::string(passwd_result->pw_name); |
| 332 #else // !defined(OS_POSIX) | 332 #else // !defined(OS_POSIX) |
| 333 return std::string(); | 333 return std::string(); |
| 334 #endif // defined(OS_POSIX) | 334 #endif // defined(OS_POSIX) |
| 335 } | 335 } |
| 336 | 336 |
| 337 } // namespace remoting | 337 } // namespace remoting |
| OLD | NEW |