Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/platform-posix.cc

Issue 7334010: second attempt at correcting fopen (hangs when trying to read from a dir) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: minor change Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 FILE* file = fopen(path, mode);
135 if (file == NULL) return NULL;
136 struct stat file_stat;
137 if (fstat(fileno(file), &file_stat) != 0) return NULL;
138 bool is_regular_file = ((file_stat.st_mode & S_IFREG) != 0);
139 if (is_regular_file) return file;
140 fclose(file);
141 return NULL;
134 } 142 }
135 143
136 144
137 bool OS::Remove(const char* path) { 145 bool OS::Remove(const char* path) {
138 return (remove(path) == 0); 146 return (remove(path) == 0);
139 } 147 }
140 148
141 149
142 const char* const OS::LogFileOpenMode = "w"; 150 const char* const OS::LogFileOpenMode = "w";
143 151
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 return ntohl(value); 435 return ntohl(value);
428 } 436 }
429 437
430 438
431 Socket* OS::CreateSocket() { 439 Socket* OS::CreateSocket() {
432 return new POSIXSocket(); 440 return new POSIXSocket();
433 } 441 }
434 442
435 443
436 } } // namespace v8::internal 444 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698