| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 168 |
| 169 char* File::GetCanonicalPath(const char* pathname) { | 169 char* File::GetCanonicalPath(const char* pathname) { |
| 170 int required_size = GetFullPathName(pathname, 0, NULL, NULL); | 170 int required_size = GetFullPathName(pathname, 0, NULL, NULL); |
| 171 char* path = static_cast<char*>(malloc(required_size)); | 171 char* path = static_cast<char*>(malloc(required_size)); |
| 172 int written = GetFullPathName(pathname, required_size, path, NULL); | 172 int written = GetFullPathName(pathname, required_size, path, NULL); |
| 173 ASSERT(written == (required_size - 1)); | 173 ASSERT(written == (required_size - 1)); |
| 174 return path; | 174 return path; |
| 175 } | 175 } |
| 176 | 176 |
| 177 | 177 |
| 178 char* File::GetContainingDirectory(char* pathname) { |
| 179 int required_size = GetFullPathName(pathname, 0, NULL, NULL); |
| 180 char* path = static_cast<char*>(malloc(required_size)); |
| 181 char* file_part = NULL; |
| 182 int written = GetFullPathName(pathname, required_size, path, &file_part); |
| 183 ASSERT(written == (required_size - 1)); |
| 184 ASSERT(file_part != NULL); |
| 185 ASSERT(file_part > path); |
| 186 ASSERT(file_part[-1] == '\\'); |
| 187 file_part[-1] = '\0'; |
| 188 return path; |
| 189 } |
| 190 |
| 191 |
| 178 const char* File::PathSeparator() { | 192 const char* File::PathSeparator() { |
| 179 return "\\"; | 193 return "\\"; |
| 180 } | 194 } |
| 181 | 195 |
| 182 | 196 |
| 183 const char* File::StringEscapedPathSeparator() { | 197 const char* File::StringEscapedPathSeparator() { |
| 184 return "\\\\"; | 198 return "\\\\"; |
| 185 } | 199 } |
| 186 | 200 |
| 187 | 201 |
| 188 File::StdioHandleType File::GetStdioHandleType(int fd) { | 202 File::StdioHandleType File::GetStdioHandleType(int fd) { |
| 189 // Treat all stdio handles as pipes. The Windows event handler and | 203 // Treat all stdio handles as pipes. The Windows event handler and |
| 190 // socket code will handle the different handle types. | 204 // socket code will handle the different handle types. |
| 191 return kPipe; | 205 return kPipe; |
| 192 } | 206 } |
| OLD | NEW |