| OLD | NEW |
| 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 "bin/file.h" | 5 #include "bin/file.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <io.h> | 8 #include <io.h> |
| 9 #include <stdio.h> | 9 #include <stdio.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 if (stat_status != 0) { | 202 if (stat_status != 0) { |
| 203 SetLastError(ERROR_FILE_NOT_FOUND); | 203 SetLastError(ERROR_FILE_NOT_FOUND); |
| 204 free(const_cast<wchar_t*>(system_name)); | 204 free(const_cast<wchar_t*>(system_name)); |
| 205 return NULL; | 205 return NULL; |
| 206 } | 206 } |
| 207 int required_size = GetFullPathNameW(system_name, 0, NULL, NULL); | 207 int required_size = GetFullPathNameW(system_name, 0, NULL, NULL); |
| 208 wchar_t* path = | 208 wchar_t* path = |
| 209 static_cast<wchar_t*>(malloc(required_size * sizeof(wchar_t))); | 209 static_cast<wchar_t*>(malloc(required_size * sizeof(wchar_t))); |
| 210 int written = GetFullPathNameW(system_name, required_size, path, NULL); | 210 int written = GetFullPathNameW(system_name, required_size, path, NULL); |
| 211 free(const_cast<wchar_t*>(system_name)); | 211 free(const_cast<wchar_t*>(system_name)); |
| 212 ASSERT(written == (required_size - 1)); | 212 ASSERT(written <= (required_size - 1)); |
| 213 char* result = StringUtils::WideToUtf8(path); | 213 char* result = StringUtils::WideToUtf8(path); |
| 214 free(path); | 214 free(path); |
| 215 return result; | 215 return result; |
| 216 } | 216 } |
| 217 | 217 |
| 218 | 218 |
| 219 char* File::GetContainingDirectory(char* pathname) { | 219 char* File::GetContainingDirectory(char* pathname) { |
| 220 struct _stat st; | 220 struct _stat st; |
| 221 wchar_t* system_name = StringUtils::Utf8ToWide(pathname); | 221 wchar_t* system_name = StringUtils::Utf8ToWide(pathname); |
| 222 int stat_status = _wstat(system_name, &st); | 222 int stat_status = _wstat(system_name, &st); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 // This is already UTF-8 encoded. | 259 // This is already UTF-8 encoded. |
| 260 return "\\\\"; | 260 return "\\\\"; |
| 261 } | 261 } |
| 262 | 262 |
| 263 | 263 |
| 264 File::StdioHandleType File::GetStdioHandleType(int fd) { | 264 File::StdioHandleType File::GetStdioHandleType(int fd) { |
| 265 // Treat all stdio handles as pipes. The Windows event handler and | 265 // Treat all stdio handles as pipes. The Windows event handler and |
| 266 // socket code will handle the different handle types. | 266 // socket code will handle the different handle types. |
| 267 return kPipe; | 267 return kPipe; |
| 268 } | 268 } |
| OLD | NEW |