OLD | NEW |
1 //===- llvm/Support/Unix/Path.inc - Unix Path Implementation ----*- C++ -*-===// | 1 //===- llvm/Support/Unix/Path.inc - Unix Path Implementation ----*- C++ -*-===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This file implements the Unix specific implementation of the Path API. | 10 // This file implements the Unix specific implementation of the Path API. |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 Dl_info DLInfo; | 186 Dl_info DLInfo; |
187 int err = dladdr(MainAddr, &DLInfo); | 187 int err = dladdr(MainAddr, &DLInfo); |
188 if (err == 0) | 188 if (err == 0) |
189 return ""; | 189 return ""; |
190 | 190 |
191 // If the filename is a symlink, we need to resolve and return the location of | 191 // If the filename is a symlink, we need to resolve and return the location of |
192 // the actual executable. | 192 // the actual executable. |
193 char link_path[MAXPATHLEN]; | 193 char link_path[MAXPATHLEN]; |
194 if (realpath(DLInfo.dli_fname, link_path)) | 194 if (realpath(DLInfo.dli_fname, link_path)) |
195 return link_path; | 195 return link_path; |
| 196 // @LOCALMOD-BEGIN |
| 197 #elif defined(__native_client__) |
| 198 // Nothing. |
| 199 // @LOCALMOD-END |
196 #else | 200 #else |
197 #error GetMainExecutable is not implemented on this host yet. | 201 #error GetMainExecutable is not implemented on this host yet. |
198 #endif | 202 #endif |
199 return ""; | 203 return ""; |
200 } | 204 } |
201 | 205 |
202 TimeValue file_status::getLastModificationTime() const { | 206 TimeValue file_status::getLastModificationTime() const { |
203 TimeValue Ret; | 207 TimeValue Ret; |
204 Ret.fromEpochTime(fs_st_mtime); | 208 Ret.fromEpochTime(fs_st_mtime); |
205 return Ret; | 209 return Ret; |
206 } | 210 } |
207 | 211 |
208 UniqueID file_status::getUniqueID() const { | 212 UniqueID file_status::getUniqueID() const { |
209 return UniqueID(fs_st_dev, fs_st_ino); | 213 return UniqueID(fs_st_dev, fs_st_ino); |
210 } | 214 } |
211 | 215 |
212 std::error_code current_path(SmallVectorImpl<char> &result) { | 216 std::error_code current_path(SmallVectorImpl<char> &result) { |
213 result.clear(); | 217 result.clear(); |
214 | 218 // @LOCALMOD-START NaCl doesn't have paths, and the translator returns an |
| 219 // error for getcwd below. Return a dummy path instead. |
| 220 #if defined(__native_client__) |
| 221 result.reserve(2); |
| 222 result.set_size(2); |
| 223 result[0] = '/'; |
| 224 result[1] = '\0'; |
| 225 return std::error_code(); |
| 226 #else // !defined(__native_client__) |
| 227 // @LOCALMOD-END |
215 const char *pwd = ::getenv("PWD"); | 228 const char *pwd = ::getenv("PWD"); |
216 llvm::sys::fs::file_status PWDStatus, DotStatus; | 229 llvm::sys::fs::file_status PWDStatus, DotStatus; |
217 if (pwd && llvm::sys::path::is_absolute(pwd) && | 230 if (pwd && llvm::sys::path::is_absolute(pwd) && |
218 !llvm::sys::fs::status(pwd, PWDStatus) && | 231 !llvm::sys::fs::status(pwd, PWDStatus) && |
219 !llvm::sys::fs::status(".", DotStatus) && | 232 !llvm::sys::fs::status(".", DotStatus) && |
220 PWDStatus.getUniqueID() == DotStatus.getUniqueID()) { | 233 PWDStatus.getUniqueID() == DotStatus.getUniqueID()) { |
221 result.append(pwd, pwd + strlen(pwd)); | 234 result.append(pwd, pwd + strlen(pwd)); |
222 return std::error_code(); | 235 return std::error_code(); |
223 } | 236 } |
224 | 237 |
(...skipping 10 matching lines...) Expand all Loading... |
235 if (errno != ENOMEM) | 248 if (errno != ENOMEM) |
236 return std::error_code(errno, std::generic_category()); | 249 return std::error_code(errno, std::generic_category()); |
237 // Otherwise there just wasn't enough space. | 250 // Otherwise there just wasn't enough space. |
238 result.reserve(result.capacity() * 2); | 251 result.reserve(result.capacity() * 2); |
239 } else | 252 } else |
240 break; | 253 break; |
241 } | 254 } |
242 | 255 |
243 result.set_size(strlen(result.data())); | 256 result.set_size(strlen(result.data())); |
244 return std::error_code(); | 257 return std::error_code(); |
| 258 // @LOCALMOD-START |
| 259 #endif // defined(__native_client__) |
| 260 // @LOCALMOD-END |
245 } | 261 } |
246 | 262 |
247 std::error_code create_directory(const Twine &path, bool IgnoreExisting) { | 263 std::error_code create_directory(const Twine &path, bool IgnoreExisting) { |
248 SmallString<128> path_storage; | 264 SmallString<128> path_storage; |
249 StringRef p = path.toNullTerminatedStringRef(path_storage); | 265 StringRef p = path.toNullTerminatedStringRef(path_storage); |
250 | 266 |
251 if (::mkdir(p.begin(), S_IRWXU | S_IRWXG) == -1) { | 267 if (::mkdir(p.begin(), S_IRWXU | S_IRWXG) == -1) { |
252 if (errno != EEXIST || !IgnoreExisting) | 268 if (errno != EEXIST || !IgnoreExisting) |
253 return std::error_code(errno, std::generic_category()); | 269 return std::error_code(errno, std::generic_category()); |
254 } | 270 } |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 #endif | 719 #endif |
704 | 720 |
705 const char *RequestedDir = getDefaultTempDir(ErasedOnReboot); | 721 const char *RequestedDir = getDefaultTempDir(ErasedOnReboot); |
706 Result.append(RequestedDir, RequestedDir + strlen(RequestedDir)); | 722 Result.append(RequestedDir, RequestedDir + strlen(RequestedDir)); |
707 } | 723 } |
708 | 724 |
709 } // end namespace path | 725 } // end namespace path |
710 | 726 |
711 } // end namespace sys | 727 } // end namespace sys |
712 } // end namespace llvm | 728 } // end namespace llvm |
OLD | NEW |