Changeset 229092 in webkit for trunk/Source/JavaScriptCore/jsc.cpp
- Timestamp:
- Feb 28, 2018, 8:38:31 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/jsc.cpp
r228950 r229092 78 78 #include <stdlib.h> 79 79 #include <string.h> 80 #include <sys/stat.h> 81 #include <sys/types.h> 80 82 #include <thread> 81 83 #include <type_traits> … … 854 856 static RefPtr<Uint8Array> fillBufferWithContentsOfFile(FILE* file) 855 857 { 856 fseek(file, 0, SEEK_END); 857 size_t bufferCapacity = ftell(file); 858 fseek(file, 0, SEEK_SET); 858 if (fseek(file, 0, SEEK_END) == -1) 859 return nullptr; 860 long bufferCapacity = ftell(file); 861 if (bufferCapacity == -1) 862 return nullptr; 863 if (fseek(file, 0, SEEK_SET) == -1) 864 return nullptr; 859 865 RefPtr<Uint8Array> result = Uint8Array::create(bufferCapacity); 860 866 size_t readSize = fread(result->data(), 1, bufferCapacity, file); 861 if (readSize != bufferCapacity)867 if (readSize != static_cast<size_t>(bufferCapacity)) 862 868 return nullptr; 863 869 return result; … … 882 888 // We might have injected "use strict"; at the top. 883 889 size_t initialSize = buffer.size(); 884 fseek(file, 0, SEEK_END); 885 size_t bufferCapacity = ftell(file); 886 fseek(file, 0, SEEK_SET); 890 if (fseek(file, 0, SEEK_END) == -1) 891 return false; 892 long bufferCapacity = ftell(file); 893 if (bufferCapacity == -1) 894 return false; 895 if (fseek(file, 0, SEEK_SET) == -1) 896 return false; 887 897 buffer.resize(bufferCapacity + initialSize); 888 898 size_t readSize = fread(buffer.data() + initialSize, 1, buffer.size(), file); … … 919 929 // Use long UNC to pass the long path name to the Windows APIs. 920 930 String longUNCPathName = WTF::makeString("\\\\?\\", fileName); 921 FILE* f = _wfopen(stringToNullTerminatedWChar(longUNCPathName).data(), L"rb"); 931 auto pathName = stringToNullTerminatedWChar(longUNCPathName); 932 struct _stat status { }; 933 if (_wstat(pathName.data(), &status)) 934 return false; 935 if ((status.st_mode & S_IFMT) != S_IFREG) 936 return false; 937 938 FILE* f = _wfopen(pathName.data(), L"rb"); 922 939 #else 923 FILE* f = fopen(fileName.utf8().data(), "r"); 940 auto pathName = fileName.utf8(); 941 struct stat status { }; 942 if (stat(pathName.data(), &status)) 943 return false; 944 if ((status.st_mode & S_IFMT) != S_IFREG) 945 return false; 946 947 FILE* f = fopen(pathName.data(), "r"); 924 948 #endif 925 949 if (!f) {
Note:
See TracChangeset
for help on using the changeset viewer.