Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 // Mac OS, FreeBSD and OpenBSD. | 30 // Mac OS, FreeBSD and OpenBSD. |
| 31 | 31 |
| 32 #include <unistd.h> | 32 #include <unistd.h> |
| 33 #include <errno.h> | 33 #include <errno.h> |
| 34 #include <time.h> | 34 #include <time.h> |
| 35 | 35 |
| 36 #include <sys/socket.h> | 36 #include <sys/socket.h> |
| 37 #include <sys/resource.h> | 37 #include <sys/resource.h> |
| 38 #include <sys/time.h> | 38 #include <sys/time.h> |
| 39 #include <sys/types.h> | 39 #include <sys/types.h> |
| 40 #include <sys/stat.h> | |
| 40 | 41 |
| 41 #include <arpa/inet.h> | 42 #include <arpa/inet.h> |
| 42 #include <netinet/in.h> | 43 #include <netinet/in.h> |
| 43 #include <netdb.h> | 44 #include <netdb.h> |
| 44 | 45 |
| 45 #if defined(ANDROID) | 46 #if defined(ANDROID) |
| 46 #define LOG_TAG "v8" | 47 #define LOG_TAG "v8" |
| 47 #include <utils/Log.h> // LOG_PRI_VA | 48 #include <utils/Log.h> // LOG_PRI_VA |
| 48 #endif | 49 #endif |
| 49 | 50 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 int OS::GetLastError() { | 124 int OS::GetLastError() { |
| 124 return errno; | 125 return errno; |
| 125 } | 126 } |
| 126 | 127 |
| 127 | 128 |
| 128 // ---------------------------------------------------------------------------- | 129 // ---------------------------------------------------------------------------- |
| 129 // POSIX stdio support. | 130 // POSIX stdio support. |
| 130 // | 131 // |
| 131 | 132 |
| 132 FILE* OS::FOpen(const char* path, const char* mode) { | 133 FILE* OS::FOpen(const char* path, const char* mode) { |
| 133 return fopen(path, mode); | 134 struct stat file_stat; |
| 135 if (stat(path, &file_stat) == 0 && (file_stat.st_mode & S_IFREG)) | |
|
Yang
2011/07/11 13:40:52
check whether the file to be opened is a regular (
| |
| 136 return fopen(path, mode); | |
| 137 return NULL; | |
| 134 } | 138 } |
| 135 | 139 |
| 136 | 140 |
| 137 bool OS::Remove(const char* path) { | 141 bool OS::Remove(const char* path) { |
| 138 return (remove(path) == 0); | 142 return (remove(path) == 0); |
| 139 } | 143 } |
| 140 | 144 |
| 141 | 145 |
| 142 const char* const OS::LogFileOpenMode = "w"; | 146 const char* const OS::LogFileOpenMode = "w"; |
| 143 | 147 |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 427 return ntohl(value); | 431 return ntohl(value); |
| 428 } | 432 } |
| 429 | 433 |
| 430 | 434 |
| 431 Socket* OS::CreateSocket() { | 435 Socket* OS::CreateSocket() { |
| 432 return new POSIXSocket(); | 436 return new POSIXSocket(); |
| 433 } | 437 } |
| 434 | 438 |
| 435 | 439 |
| 436 } } // namespace v8::internal | 440 } } // namespace v8::internal |
| OLD | NEW |