From 822bf38918e2599d58b22b1712427fa0acec5205 Mon Sep 17 00:00:00 2001 From: Yijia Zhang Date: Thu, 27 Jun 2024 16:12:04 -0700 Subject: [PATCH] Clean up SbFile references. Change-Id: I3871fa9b956c5b936507388b7a2cad76a1d67037 --- base/files/file_enumerator_starboard.cc | 2 +- starboard/common/file.cc | 4 ++ starboard/common/file.h | 4 +- starboard/elf_loader/file_impl.cc | 22 ++++++----- starboard/elf_loader/file_impl.h | 2 +- starboard/elf_loader/lz4_file_impl.cc | 8 ++-- .../shared/posix/storage_write_record.cc | 37 ++++++++++--------- .../file_atomic_replace_write_file.cc | 21 ++++++----- .../starboard/file_mode_string_to_flags.cc | 21 +++++++---- .../file_storage/storage_close_record.cc | 8 ++-- .../file_storage/storage_delete_record.cc | 5 ++- .../file_storage/storage_get_record_size.cc | 12 +++--- .../starboard/file_storage/storage_internal.h | 3 +- .../file_storage/storage_open_record.cc | 9 +++-- .../file_storage/storage_read_record.cc | 11 ++++-- starboard/shared/win32/log_file_impl.cc | 26 +++++++------ .../shared/win32/storage_write_record.cc | 29 +++++++-------- third_party/boringssl/src/crypto/bio/file.c | 1 - .../src/include/freetype/config/ftstdlib.h | 20 +++++----- 19 files changed, 135 insertions(+), 110 deletions(-) diff --git a/base/files/file_enumerator_starboard.cc b/base/files/file_enumerator_starboard.cc index 4f269e28dd4a..71010bf0d6f0 100644 --- a/base/files/file_enumerator_starboard.cc +++ b/base/files/file_enumerator_starboard.cc @@ -126,7 +126,7 @@ std::vector FileEnumerator::ReadDirectory( FilePath full_name = source.Append(filename); // TODO: Make sure this follows symlinks on relevant platforms. if (stat(full_name.value().c_str(), &info.stat_) != 0) { - DPLOG(ERROR) << "Couldn't SbFileGetInfo on " << full_name.value(); + DPLOG(ERROR) << "Couldn't stat on " << full_name.value(); memset(&info.stat_, 0, sizeof(info.stat_)); } return info; diff --git a/starboard/common/file.cc b/starboard/common/file.cc index 9cb288ccb652..bc358451a7cc 100644 --- a/starboard/common/file.cc +++ b/starboard/common/file.cc @@ -42,6 +42,10 @@ bool DirectoryCloseLogFailure(const char* path, SbDirectory dir) { } // namespace +bool IsValid(int file) { + return file >= 0; +} + ssize_t ReadAll(int fd, void* data, int size) { if (fd < 0 || size < 0) { return -1; diff --git a/starboard/common/file.h b/starboard/common/file.h index 15b8f4227850..6647d3ea7aba 100644 --- a/starboard/common/file.h +++ b/starboard/common/file.h @@ -38,6 +38,8 @@ namespace starboard { +bool IsValid(int file); + ssize_t ReadAll(int fd, void* data, int size); void RecordFileWriteStat(int write_file_result); @@ -77,7 +79,7 @@ class ScopedFile { int file() const { return file_; } - bool IsValid() const { return file_ >= 0; } + bool IsValid() const { return starboard::IsValid(file_); } int64_t Seek(SbFileWhence whence, int64_t offset) const { return lseek(file_, static_cast(offset), static_cast(whence)); diff --git a/starboard/elf_loader/file_impl.cc b/starboard/elf_loader/file_impl.cc index 951db5fdbc09..96a0ec81cc4c 100644 --- a/starboard/elf_loader/file_impl.cc +++ b/starboard/elf_loader/file_impl.cc @@ -14,6 +14,10 @@ #include "starboard/elf_loader/file_impl.h" +#include +#include + +#include "starboard/common/file.h" #include "starboard/common/log.h" #include "starboard/elf_loader/log.h" @@ -31,7 +35,7 @@ void LogLastError(const char* msg) { namespace starboard { namespace elf_loader { -FileImpl::FileImpl() : file_(NULL) {} +FileImpl::FileImpl() : file_(-1) {} FileImpl::~FileImpl() { Close(); @@ -40,7 +44,7 @@ FileImpl::~FileImpl() { bool FileImpl::Open(const char* name) { SB_DLOG(INFO) << "Loading: " << name; name_ = name; - file_ = SbFileOpen(name, kSbFileOpenOnly | kSbFileRead, NULL, NULL); + file_ = open(name, O_RDONLY, S_IRUSR | S_IWUSR); if (!file_) { return false; } @@ -51,17 +55,17 @@ bool FileImpl::ReadFromOffset(int64_t offset, char* buffer, int size) { if (!file_) { return false; } - int64_t ret = SbFileSeek(file_, kSbFileFromBegin, offset); - SB_DLOG(INFO) << "SbFileSeek: ret=" << ret; + int64_t ret = lseek(file_, offset, SEEK_SET); + SB_DLOG(INFO) << "lseek: ret=" << ret; if (ret == -1) { - LogLastError("SbFileSeek: failed"); + LogLastError("lseek: failed"); return false; } - int count = SbFileReadAll(file_, buffer, size); - SB_DLOG(INFO) << "SbFileReadAll: count=" << count; + int count = starboard::ReadAll(file_, buffer, size); + SB_DLOG(INFO) << "ReadAll: count=" << count; if (count == -1) { - LogLastError("SbFileReadAll failed"); + LogLastError("ReadAll failed"); return false; } return true; @@ -69,7 +73,7 @@ bool FileImpl::ReadFromOffset(int64_t offset, char* buffer, int size) { void FileImpl::Close() { if (file_) { - SbFileClose(file_); + close(file_); } } diff --git a/starboard/elf_loader/file_impl.h b/starboard/elf_loader/file_impl.h index a6a30bdc8cf2..a1a2f9525be5 100644 --- a/starboard/elf_loader/file_impl.h +++ b/starboard/elf_loader/file_impl.h @@ -35,7 +35,7 @@ class FileImpl : public File { const std::string& GetName() override; protected: - SbFile file_; + int file_; std::string name_; FileImpl(const FileImpl&) = delete; diff --git a/starboard/elf_loader/lz4_file_impl.cc b/starboard/elf_loader/lz4_file_impl.cc index 1ffbdfa921ab..9285f62ce2d5 100644 --- a/starboard/elf_loader/lz4_file_impl.cc +++ b/starboard/elf_loader/lz4_file_impl.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include + #include #include @@ -73,9 +75,9 @@ bool LZ4FileImpl::Open(const char* name) { return false; } - SbFileInfo file_info; + struct stat file_info; - if (!FileImpl::Open(name) || !SbFileGetInfo(file_, &file_info)) { + if (!FileImpl::Open(name) || fstat(file_, &file_info)) { return false; } @@ -111,7 +113,7 @@ bool LZ4FileImpl::Open(const char* name) { // uncompressed block size. int max_compressed_buffer_size = GetBlockSize(&frame_info); - bool result = Decompress(file_info.size, header_size, + bool result = Decompress(file_info.st_size, header_size, max_compressed_buffer_size, source_bytes_hint); int64_t decompression_end_time_us = CurrentMonotonicTime(); diff --git a/starboard/shared/posix/storage_write_record.cc b/starboard/shared/posix/storage_write_record.cc index 7a23c6621490..4205cabb32b8 100644 --- a/starboard/shared/posix/storage_write_record.cc +++ b/starboard/shared/posix/storage_write_record.cc @@ -14,13 +14,15 @@ #include "starboard/common/storage.h" +#include + #include #include +#include "starboard/common/file.h" #include "starboard/common/log.h" #include "starboard/common/string.h" #include "starboard/configuration_constants.h" -#include "starboard/file.h" #include "starboard/shared/starboard/file_storage/storage_internal.h" const char kTempFileSuffix[] = ".temp"; @@ -45,24 +47,23 @@ bool SbStorageWriteRecord(SbStorageRecord record, starboard::strlcat(temp_file_path.data(), kTempFileSuffix, kSbFileMaxPath); SbFileError error; - SbFile temp_file = SbFileOpen( - temp_file_path.data(), kSbFileCreateAlways | kSbFileWrite | kSbFileRead, - NULL, &error); - if (error != kSbFileOk) { + int temp_file = open(temp_file_path.data(), O_CREAT | O_TRUNC | O_RDWR, + S_IRUSR | S_IWUSR); + if (!starboard::IsValid(temp_file)) { return false; } - SbFileTruncate(temp_file, 0); + ftruncate(temp_file, 0); const char* source = data; int64_t to_write = data_size; while (to_write > 0) { int to_write_max = static_cast(std::min(to_write, static_cast(kSbInt32Max))); - int bytes_written = SbFileWrite(temp_file, source, to_write_max); + int bytes_written = write(temp_file, source, to_write_max); if (bytes_written < 0) { - SbFileClose(temp_file); - SbFileDelete(temp_file_path.data()); + close(temp_file); + unlink(temp_file_path.data()); return false; } @@ -70,24 +71,24 @@ bool SbStorageWriteRecord(SbStorageRecord record, to_write -= bytes_written; } - SbFileFlush(temp_file); + fsync(temp_file); - if (SbFileIsValid(record->file) && !SbFileClose(record->file)) { - SbFileClose(temp_file); - SbFileDelete(temp_file_path.data()); + if (starboard::IsValid(record->file) && (close(record->file) < 0)) { + close(temp_file); + unlink(temp_file_path.data()); return false; } - record->file = kSbFileInvalid; + record->file = -1; - if ((!SbFileDelete(original_file_path.data())) || + if (unlink(original_file_path.data()) || (rename(temp_file_path.data(), original_file_path.data()) != 0)) { - SbFileClose(temp_file); - SbFileDelete(temp_file_path.data()); + close(temp_file); + unlink(temp_file_path.data()); return false; } - SbFileFlush(temp_file); + fsync(temp_file); record->file = temp_file; diff --git a/starboard/shared/starboard/file_atomic_replace_write_file.cc b/starboard/shared/starboard/file_atomic_replace_write_file.cc index 5d7e48925853..3b14875e2055 100644 --- a/starboard/shared/starboard/file_atomic_replace_write_file.cc +++ b/starboard/shared/starboard/file_atomic_replace_write_file.cc @@ -14,6 +14,9 @@ #include "starboard/shared/starboard/file_atomic_replace_write_file.h" +#include +#include + #include #include "starboard/common/file.h" @@ -27,15 +30,13 @@ namespace starboard { bool SbFileAtomicReplaceWriteFile(const char* path, const char* data, int64_t data_size) { - SbFileError error; - SbFile temp_file = SbFileOpen( - path, kSbFileCreateAlways | kSbFileWrite | kSbFileRead, NULL, &error); + int temp_file = open(path, O_CREAT | O_TRUNC | O_RDWR, S_IRUSR | S_IWUSR); - if (error != kSbFileOk) { + if (temp_file < 0) { return false; } - SbFileTruncate(temp_file, 0); + ftruncate(temp_file, 0); const char* source = data; int64_t to_write = data_size; @@ -43,12 +44,12 @@ bool SbFileAtomicReplaceWriteFile(const char* path, while (to_write > 0) { const int to_write_max = static_cast(std::min(to_write, static_cast(kSbInt32Max))); - const int bytes_written = SbFileWrite(temp_file, source, to_write_max); + const int bytes_written = write(temp_file, source, to_write_max); RecordFileWriteStat(bytes_written); if (bytes_written < 0) { - SbFileClose(temp_file); - SbFileDelete(path); + close(temp_file); + unlink(path); return false; } @@ -56,9 +57,9 @@ bool SbFileAtomicReplaceWriteFile(const char* path, to_write -= bytes_written; } - SbFileFlush(temp_file); + fsync(temp_file); - if (!SbFileClose(temp_file)) { + if (close(temp_file)) { return false; } return true; diff --git a/starboard/shared/starboard/file_mode_string_to_flags.cc b/starboard/shared/starboard/file_mode_string_to_flags.cc index b69d9741e86b..ab4ec9bf3e88 100644 --- a/starboard/shared/starboard/file_mode_string_to_flags.cc +++ b/starboard/shared/starboard/file_mode_string_to_flags.cc @@ -12,9 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include + +#include "starboard/common/file.h" #include "starboard/common/log.h" #include "starboard/common/string.h" -#include "starboard/file.h" namespace { bool IsUpdate(const char* mode) { @@ -42,21 +44,26 @@ int SbFileModeStringToFlags(const char* mode) { switch (mode[0]) { case 'r': if (IsUpdate(mode + 1)) { - flags |= kSbFileWrite; + flags |= O_RDWR; + } else { + flags |= O_RDONLY; } - flags |= kSbFileOpenOnly | kSbFileRead; break; case 'w': if (IsUpdate(mode + 1)) { - flags |= kSbFileRead; + flags |= O_RDWR; + } else { + flags |= O_WRONLY; } - flags |= kSbFileCreateAlways | kSbFileWrite; + flags |= O_CREAT | O_TRUNC; break; case 'a': if (IsUpdate(mode + 1)) { - flags |= kSbFileRead; + flags |= O_RDONLY; + } else { + flags |= O_RDWR; } - flags |= kSbFileOpenAlways | kSbFileWrite; + flags |= O_CREAT; break; default: SB_NOTREACHED(); diff --git a/starboard/shared/starboard/file_storage/storage_close_record.cc b/starboard/shared/starboard/file_storage/storage_close_record.cc index 70f850a6386d..0f39d69bad71 100644 --- a/starboard/shared/starboard/file_storage/storage_close_record.cc +++ b/starboard/shared/starboard/file_storage/storage_close_record.cc @@ -14,7 +14,9 @@ #include "starboard/common/storage.h" -#include "starboard/file.h" +#include + +#include "starboard/common/file.h" #include "starboard/shared/starboard/file_storage/storage_internal.h" bool SbStorageCloseRecord(SbStorageRecord record) { @@ -22,8 +24,8 @@ bool SbStorageCloseRecord(SbStorageRecord record) { return false; } - if (SbFileIsValid(record->file)) { - SbFileClose(record->file); + if (starboard::IsValid(record->file)) { + close(record->file); } delete record; diff --git a/starboard/shared/starboard/file_storage/storage_delete_record.cc b/starboard/shared/starboard/file_storage/storage_delete_record.cc index 3d32365883c6..0d1bf129c858 100644 --- a/starboard/shared/starboard/file_storage/storage_delete_record.cc +++ b/starboard/shared/starboard/file_storage/storage_delete_record.cc @@ -14,10 +14,11 @@ #include "starboard/common/storage.h" +#include + #include #include "starboard/configuration_constants.h" -#include "starboard/file.h" #include "starboard/shared/starboard/file_storage/storage_internal.h" #if SB_API_VERSION < 16 @@ -33,5 +34,5 @@ bool SbStorageDeleteRecord(const char* name) { return false; } - return SbFileDelete(path.data()); + return !unlink(path.data()); } diff --git a/starboard/shared/starboard/file_storage/storage_get_record_size.cc b/starboard/shared/starboard/file_storage/storage_get_record_size.cc index deda29f21bff..961e67e35994 100644 --- a/starboard/shared/starboard/file_storage/storage_get_record_size.cc +++ b/starboard/shared/starboard/file_storage/storage_get_record_size.cc @@ -14,7 +14,7 @@ #include "starboard/common/storage.h" -#include "starboard/file.h" +#include "starboard/common/file.h" #include "starboard/shared/starboard/file_storage/storage_internal.h" int64_t SbStorageGetRecordSize(SbStorageRecord record) { @@ -22,15 +22,15 @@ int64_t SbStorageGetRecordSize(SbStorageRecord record) { return -1; } - if (!SbFileIsValid(record->file)) { + if (!starboard::IsValid(record->file)) { return -1; } - SbFileInfo info; - bool success = SbFileGetInfo(record->file, &info); - if (!success) { + struct stat info; + bool success = !fstat(record->file, &info); + if (success) { return -1; } - return info.size; + return info.st_size; } diff --git a/starboard/shared/starboard/file_storage/storage_internal.h b/starboard/shared/starboard/file_storage/storage_internal.h index c59edf50d377..268a2d1f462e 100644 --- a/starboard/shared/starboard/file_storage/storage_internal.h +++ b/starboard/shared/starboard/file_storage/storage_internal.h @@ -21,13 +21,12 @@ #include "starboard/common/storage.h" #include "starboard/common/string.h" -#include "starboard/file.h" #include "starboard/shared/internal_only.h" #include "starboard/shared/starboard/get_home_directory.h" struct SbStorageRecordPrivate { void* unused_user; // deprecated in SB 16 - SbFile file; + int file; std::string name; }; diff --git a/starboard/shared/starboard/file_storage/storage_open_record.cc b/starboard/shared/starboard/file_storage/storage_open_record.cc index 5eee17162270..eaa32c79790e 100644 --- a/starboard/shared/starboard/file_storage/storage_open_record.cc +++ b/starboard/shared/starboard/file_storage/storage_open_record.cc @@ -14,11 +14,13 @@ #include "starboard/common/storage.h" +#include + #include +#include "starboard/common/file.h" #include "starboard/common/log.h" #include "starboard/configuration_constants.h" -#include "starboard/file.h" #include "starboard/shared/starboard/file_storage/storage_internal.h" #if SB_API_VERSION < 16 @@ -36,9 +38,8 @@ SbStorageRecord SbStorageOpenRecord(const char* name) { // This will always create the storage file, even if it is just opened and // closed without doing any operation. - SbFile file = SbFileOpen( - path.data(), kSbFileOpenAlways | kSbFileRead | kSbFileWrite, NULL, NULL); - if (!SbFileIsValid(file)) { + int file = open(path.data(), O_CREAT | O_RDWR, S_IRUSR | S_IWUSR); + if (!starboard::IsValid(file)) { return kSbStorageInvalidRecord; } diff --git a/starboard/shared/starboard/file_storage/storage_read_record.cc b/starboard/shared/starboard/file_storage/storage_read_record.cc index ff316e1abdd2..7dc3745dc960 100644 --- a/starboard/shared/starboard/file_storage/storage_read_record.cc +++ b/starboard/shared/starboard/file_storage/storage_read_record.cc @@ -14,8 +14,11 @@ #include "starboard/common/storage.h" +#include + #include +#include "starboard/common/file.h" #include "starboard/common/log.h" #include "starboard/common/string.h" #include "starboard/shared/starboard/file_storage/storage_internal.h" @@ -27,16 +30,16 @@ int64_t SbStorageReadRecord(SbStorageRecord record, return -1; } - if (!SbFileIsValid(record->file)) { + if (!starboard::IsValid(record->file)) { return -1; } - int64_t total = SbFileSeek(record->file, kSbFileFromEnd, 0); + int64_t total = lseek(record->file, 0, SEEK_END); if (total > data_size) { total = data_size; } - int64_t position = SbFileSeek(record->file, kSbFileFromBegin, 0); + int64_t position = lseek(record->file, 0, SEEK_SET); if (position != 0) { return -1; } @@ -46,7 +49,7 @@ int64_t SbStorageReadRecord(SbStorageRecord record, while (to_read > 0) { int to_read_max = static_cast(std::min(to_read, static_cast(kSbInt32Max))); - int bytes_read = SbFileRead(record->file, destination, to_read_max); + int bytes_read = read(record->file, destination, to_read_max); if (bytes_read < 0) { return -1; } diff --git a/starboard/shared/win32/log_file_impl.cc b/starboard/shared/win32/log_file_impl.cc index 022f7d259880..9158e6e70ec4 100644 --- a/starboard/shared/win32/log_file_impl.cc +++ b/starboard/shared/win32/log_file_impl.cc @@ -14,7 +14,9 @@ #include "starboard/shared/win32/log_file_impl.h" +#include #include +#include #include #include @@ -32,15 +34,15 @@ namespace { pthread_mutex_t log_mutex = PTHREAD_MUTEX_INITIALIZER; -SbFile log_file = kSbFileInvalid; +int log_file = -1; // SbMutex is not reentrant, so factor out close log file functionality for use // by other functions. void CloseLogFileWithoutLock() { - if (SbFileIsValid(log_file)) { - SbFileFlush(log_file); - SbFileClose(log_file); - log_file = kSbFileInvalid; + if (starboard::IsValid(log_file)) { + fsync(log_file); + close(log_file); + log_file = -1; } } @@ -57,8 +59,8 @@ void CloseLogFile() { } void OpenLogInCacheDirectory(const char* log_file_name, int creation_flags) { - SB_DCHECK((creation_flags & kSbFileOpenAlways) || - (creation_flags & kSbFileCreateAlways)); + SB_DCHECK((creation_flags & O_CREAT) || + ((creation_flags & O_CREAT) && (creation_flags & O_TRUNC))); SB_DCHECK(strlen(log_file_name) != 0); SB_DCHECK(strchr(log_file_name, kSbFileSepChar) == nullptr); std::vector out_path(kSbFileMaxPath + 1); @@ -92,8 +94,8 @@ void OpenLogFile(const char* path, const int creation_flags) { pthread_mutex_lock(&log_mutex); CloseLogFileWithoutLock(); if ((path != nullptr) && (path[0] != '\0')) { - log_file = SbFileOpen(path, flags, nullptr, nullptr); - SB_DCHECK(SbFileIsValid(log_file)); + log_file = open(path, flags, S_IRUSR | S_IWUSR); + SB_DCHECK(starboard::IsValid(log_file)); } pthread_mutex_unlock(&log_mutex); @@ -104,16 +106,16 @@ void WriteToLogFile(const char* text, const int text_length) { return; } pthread_mutex_lock(&log_mutex); - if (!SbFileIsValid(log_file)) { + if (!starboard::IsValid(log_file)) { pthread_mutex_unlock(&log_mutex); return; } - int bytes_written = SbFileWriteAll(log_file, text, text_length); + int bytes_written = starboard::WriteAll(log_file, text, text_length); RecordFileWriteStat(bytes_written); SB_DCHECK(text_length == bytes_written); - SbFileFlush(log_file); + fsync(log_file); pthread_mutex_unlock(&log_mutex); } diff --git a/starboard/shared/win32/storage_write_record.cc b/starboard/shared/win32/storage_write_record.cc index 012d94bb4b72..0162e474819e 100644 --- a/starboard/shared/win32/storage_write_record.cc +++ b/starboard/shared/win32/storage_write_record.cc @@ -14,15 +14,17 @@ #include "starboard/common/storage.h" +#include +#include #include #include #include +#include "starboard/common/file.h" #include "starboard/common/log.h" #include "starboard/common/string.h" #include "starboard/configuration_constants.h" -#include "starboard/file.h" #include "starboard/shared/starboard/file_storage/storage_internal.h" #include "starboard/shared/win32/file_internal.h" #include "starboard/shared/win32/wchar_utils.h" @@ -49,24 +51,22 @@ bool SbStorageWriteRecord(SbStorageRecord record, starboard::strlcat(temp_file_path.data(), kTempFileSuffix, kSbFileMaxPath); SbFileError error; - SbFile temp_file = SbFileOpen( - temp_file_path.data(), kSbFileCreateAlways | kSbFileWrite | kSbFileRead, - NULL, &error); + int file = open(path.data(), O_CREAT | O_TRUNC | O_RDWR, S_IRUSR | S_IWUSR); if (error != kSbFileOk) { return false; } - SbFileTruncate(temp_file, 0); + ftruncate(temp_file, 0); const char* source = data; int64_t to_write = data_size; while (to_write > 0) { int to_write_max = static_cast(std::min(to_write, static_cast(kSbInt32Max))); - int bytes_written = SbFileWrite(temp_file, source, to_write_max); + int bytes_written = write(temp_file, source, to_write_max); if (bytes_written < 0) { - SbFileClose(temp_file); - SbFileDelete(temp_file_path.data()); + close(temp_file); + unlink(temp_file_path.data()); return false; } @@ -74,15 +74,15 @@ bool SbStorageWriteRecord(SbStorageRecord record, to_write -= bytes_written; } - SbFileFlush(temp_file); + fsync(temp_file); - if (SbFileIsValid(record->file) && !SbFileClose(record->file)) { + if (starboard::IsValid(record->file) && close(record->file)) { return false; } - record->file = kSbFileInvalid; + record->file = -1; - if (!SbFileClose(temp_file)) { + if (close(temp_file)) { return false; } @@ -96,9 +96,8 @@ bool SbStorageWriteRecord(SbStorageRecord record, NULL, 0, NULL, NULL) == 0) { return false; } - SbFile new_record_file = - SbFileOpen(original_file_path.data(), - kSbFileOpenOnly | kSbFileWrite | kSbFileRead, NULL, NULL); + int new_record_file = + open(original_file_path.data(), O_RDWR, S_IRUSR | S_IWUSR); record->file = new_record_file; return true; diff --git a/third_party/boringssl/src/crypto/bio/file.c b/third_party/boringssl/src/crypto/bio/file.c index 6f75687f7c59..a9614e098f42 100644 --- a/third_party/boringssl/src/crypto/bio/file.c +++ b/third_party/boringssl/src/crypto/bio/file.c @@ -177,7 +177,6 @@ BIO *BIO_new_file(const char *filename, const char *mode) { #if defined(OPENSSL_SYS_STARBOARD) SbFile sb_file = kSbFileInvalid; SbFileError error = kSbFileOk; - int file = open(filename, SbFileModeStringToFlags(mode)); sb_file = SbFileOpen(filename, SbFileModeStringToFlags(mode), NULL, &error); if (!SbFileIsValid(sb_file)) { OPENSSL_PUT_SYSTEM_ERROR(); diff --git a/third_party/freetype/src/include/freetype/config/ftstdlib.h b/third_party/freetype/src/include/freetype/config/ftstdlib.h index 42c0e3f09df6..857161f06671 100644 --- a/third_party/freetype/src/include/freetype/config/ftstdlib.h +++ b/third_party/freetype/src/include/freetype/config/ftstdlib.h @@ -110,20 +110,18 @@ #if defined( STARBOARD ) +#include +#include + #include "starboard/string.h" #include "starboard/file.h" -#ifndef SEEK_SET -#define SEEK_SET kSbFileFromBegin -#define SEEK_CUR kSbFileFromCurrent -#define SEEK_END kSbFileFromEnd -#endif -#define FT_FILE SbFilePrivate -#define ft_fclose SbFileClose -#define ft_fopen(p, m) SbFileOpen((p), SbFileModeStringToFlags(m), NULL, NULL) -#define ft_fread(b, s, n, f) SbFileRead((f), (char *)(b), (s) * (n)) -#define ft_fseek(f, o, w) SbFileSeek((f), (w), (o)) -#define ft_ftell(f) SbFileSeek((f), kSbFileFromCurrent, 0) +#define FT_FILE int +#define ft_fclose close +#define ft_fopen(p, m) open((p), SbFileModeStringToFlags(m)) +#define ft_fread(b, s, n, f) read((f), (char *)(b), (s) * (n)) +#define ft_fseek(f, o, w) lseek((f), (o), (w)) +#define ft_ftell(f) lseek((f), 0, SEEK_SET) #define ft_sprintf sprintf #else #include