| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 <fcntl.h> | 5 #include <fcntl.h> |
| 6 #include <io.h> | 6 #include <io.h> |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
| 10 | 10 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 bool File::Create(const char* name) { | 120 bool File::Create(const char* name) { |
| 121 int fd = open(name, O_RDONLY | O_CREAT, 0666); | 121 int fd = open(name, O_RDONLY | O_CREAT, 0666); |
| 122 if (fd < 0) { | 122 if (fd < 0) { |
| 123 return false; | 123 return false; |
| 124 } | 124 } |
| 125 return (close(fd) == 0); | 125 return (close(fd) == 0); |
| 126 } | 126 } |
| 127 | 127 |
| 128 | 128 |
| 129 bool File::Delete(const char* name) { |
| 130 int status = remove(name); |
| 131 if (status == -1) { |
| 132 return false; |
| 133 } |
| 134 return true; |
| 135 } |
| 136 |
| 137 |
| 129 bool File::IsAbsolutePath(const char* pathname) { | 138 bool File::IsAbsolutePath(const char* pathname) { |
| 130 // Should we consider network paths? | 139 // Should we consider network paths? |
| 131 if (pathname == NULL) return false; | 140 if (pathname == NULL) return false; |
| 132 return (strlen(pathname) > 2) && | 141 return (strlen(pathname) > 2) && |
| 133 (pathname[1] == ':') && | 142 (pathname[1] == ':') && |
| 134 (pathname[2] == '\\'); | 143 (pathname[2] == '\\'); |
| 135 } | 144 } |
| 136 | 145 |
| 137 | 146 |
| 138 char* File::GetCanonicalPath(const char* pathname) { | 147 char* File::GetCanonicalPath(const char* pathname) { |
| 139 int required_size = GetFullPathName(pathname, 0, NULL, NULL); | 148 int required_size = GetFullPathName(pathname, 0, NULL, NULL); |
| 140 char* path = static_cast<char*>(malloc(required_size)); | 149 char* path = static_cast<char*>(malloc(required_size)); |
| 141 int written = GetFullPathName(pathname, required_size, path, NULL); | 150 int written = GetFullPathName(pathname, required_size, path, NULL); |
| 142 ASSERT(written == (required_size - 1)); | 151 ASSERT(written == (required_size - 1)); |
| 143 return path; | 152 return path; |
| 144 } | 153 } |
| 145 | 154 |
| 146 | 155 |
| 147 const char* File::PathSeparator() { | 156 const char* File::PathSeparator() { |
| 148 return "\\"; | 157 return "\\"; |
| 149 } | 158 } |
| 150 | 159 |
| 151 | 160 |
| 152 const char* File::StringEscapedPathSeparator() { | 161 const char* File::StringEscapedPathSeparator() { |
| 153 return "\\\\"; | 162 return "\\\\"; |
| 154 } | 163 } |
| OLD | NEW |