mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-12 22:50:08 +00:00
8378764: fileStream::fileSize() fails for >2GB files on Windows
Reviewed-by: stuefe, dholmes, amenkov
This commit is contained in:
parent
75b2ee2680
commit
1de03224b8
@ -888,6 +888,14 @@ void* os::lookup_function(const char* name) {
|
||||
return dlsym(RTLD_DEFAULT, name);
|
||||
}
|
||||
|
||||
int64_t os::ftell(FILE* file) {
|
||||
return ::ftell(file);
|
||||
}
|
||||
|
||||
int os::fseek(FILE* file, int64_t offset, int whence) {
|
||||
return ::fseek(file, offset, whence);
|
||||
}
|
||||
|
||||
jlong os::lseek(int fd, jlong offset, int whence) {
|
||||
return (jlong) ::lseek(fd, offset, whence);
|
||||
}
|
||||
|
||||
@ -5114,6 +5114,13 @@ jlong os::seek_to_file_offset(int fd, jlong offset) {
|
||||
return (jlong)::_lseeki64(fd, (__int64)offset, SEEK_SET);
|
||||
}
|
||||
|
||||
int64_t os::ftell(FILE* file) {
|
||||
return ::_ftelli64(file);
|
||||
}
|
||||
|
||||
int os::fseek(FILE* file, int64_t offset, int whence) {
|
||||
return ::_fseeki64(file,offset, whence);
|
||||
}
|
||||
|
||||
jlong os::lseek(int fd, jlong offset, int whence) {
|
||||
return (jlong) ::_lseeki64(fd, offset, whence);
|
||||
|
||||
@ -721,6 +721,8 @@ class os: AllStatic {
|
||||
static int open(const char *path, int oflag, int mode);
|
||||
static FILE* fdopen(int fd, const char* mode);
|
||||
static FILE* fopen(const char* path, const char* mode);
|
||||
static int64_t ftell(FILE* file);
|
||||
static int fseek(FILE* file, int64_t offset, int whence);
|
||||
static jlong lseek(int fd, jlong offset, int whence);
|
||||
static bool file_exists(const char* file);
|
||||
|
||||
|
||||
@ -611,15 +611,15 @@ void fileStream::write(const char* s, size_t len) {
|
||||
}
|
||||
}
|
||||
|
||||
long fileStream::fileSize() {
|
||||
long size = -1;
|
||||
int64_t fileStream::fileSize() {
|
||||
int64_t size = -1;
|
||||
if (_file != nullptr) {
|
||||
long pos = ::ftell(_file);
|
||||
int64_t pos = os::ftell(_file);
|
||||
if (pos < 0) return pos;
|
||||
if (::fseek(_file, 0, SEEK_END) == 0) {
|
||||
size = ::ftell(_file);
|
||||
if (os::fseek(_file, 0, SEEK_END) == 0) {
|
||||
size = os::ftell(_file);
|
||||
}
|
||||
::fseek(_file, pos, SEEK_SET);
|
||||
os::fseek(_file, pos, SEEK_SET);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
@ -312,7 +312,7 @@ class fileStream : public outputStream {
|
||||
fclose(_file);
|
||||
_need_close = false;
|
||||
}
|
||||
long fileSize();
|
||||
int64_t fileSize();
|
||||
void flush();
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user