Skip to content

Commit

Permalink
Address comments.
Browse files Browse the repository at this point in the history
Change-Id: I21936ce049bc6639ddeddf2034a76d9557ca8e52
  • Loading branch information
yjzhang111 committed Aug 12, 2024
1 parent 9bfe8ab commit 86e12a3
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 14 deletions.
6 changes: 0 additions & 6 deletions starboard/common/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@

namespace starboard {

struct FileStruct {
int fd;
};

typedef FileStruct* FilePtr;

bool FileCanOpen(const char* path, int flags);

bool IsValid(int file);
Expand Down
2 changes: 1 addition & 1 deletion starboard/common/file_wrapper.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016 The Cobalt Authors. All Rights Reserved.
// Copyright 2024 The Cobalt Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@ TEST(PosixFileModeStringToFlagsTest, Empties) {
EXPECT_EQ(0, FileModeStringToFlags(""));
}

TEST(PosixFileModeStringToFlagsTest, Arr) {
TEST(PosixFileModeStringToFlagsTest, ReadMode) {
EXPECT_EQ(O_RDONLY, FileModeStringToFlags("r"));
EXPECT_EQ(O_RDWR, FileModeStringToFlags("r+"));
EXPECT_EQ(O_RDWR, FileModeStringToFlags("r+b"));
EXPECT_EQ(O_RDWR, FileModeStringToFlags("rb+"));
}

TEST(PosixFileModeStringToFlagsTest, Wuh) {
TEST(PosixFileModeStringToFlagsTest, WriteMode) {
EXPECT_EQ(O_CREAT | O_TRUNC | O_WRONLY, FileModeStringToFlags("w"));
EXPECT_EQ(O_CREAT | O_TRUNC | O_RDWR, FileModeStringToFlags("w+"));
EXPECT_EQ(O_CREAT | O_TRUNC | O_RDWR, FileModeStringToFlags("w+b"));
EXPECT_EQ(O_CREAT | O_TRUNC | O_RDWR, FileModeStringToFlags("wb+"));
}

TEST(PosixFileModeStringToFlagsTest, Aah) {
TEST(PosixFileModeStringToFlagsTest, AppendMode) {
EXPECT_EQ(O_CREAT | O_WRONLY, FileModeStringToFlags("a"));
EXPECT_EQ(O_CREAT | O_RDWR, FileModeStringToFlags("a+"));
EXPECT_EQ(O_CREAT | O_RDWR, FileModeStringToFlags("a+b"));
Expand Down
3 changes: 1 addition & 2 deletions starboard/shared/starboard/player/video_dmp_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,11 @@ SB_ONCE_INITIALIZE_FUNCTION(PlayerToWriterMap, GetOrCreatePlayerToWriterMap);
VideoDmpWriter::VideoDmpWriter() : file_(-1) {
int index = 0;
std::string file_name;
while (IsValid(file_)) {
while (!IsValid(file_)) {
std::stringstream ss;
ss << "video_" << index << ".dmp";
file_name = ss.str();

bool created = false;
file_ =
open(file_name.c_str(), O_CREAT | O_EXCL | O_WRONLY, S_IRUSR | S_IWUSR);
++index;
Expand Down
2 changes: 1 addition & 1 deletion third_party/boringssl/src/crypto/bio/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ static int MS_CALLBACK file_gets(BIO *bp, char *buf, int size) {
ret = -1;
struct stat info;
fstat(((FilePtr)bp->ptr)->fd, &info);
int64_t current = lseek(((FilePtr)bp->ptr)->fd, SEEK_CUR, 0);
int64_t current = lseek(((FilePtr)bp->ptr)->fd, 0, SEEK_CUR);
int64_t remaining = info.st_size - current;
int64_t max = (size > remaining ? remaining : size - 1);
int index = 0;
Expand Down
2 changes: 1 addition & 1 deletion third_party/musl/src/starboard/sys/stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ int stat(const char *path, struct stat *file_info)
}

// In SB_API_VERSION < 16, all files are opened with S_IRUSR | S_IWUSR.
// See http://shortn/_UxFowRzNXq.
// See starboard/shared/posix/impl/file_open.h.
file_info->st_mode = S_IRUSR | S_IWUSR;
if (out_info.is_directory){
file_info->st_mode |= S_IFDIR;
Expand Down

0 comments on commit 86e12a3

Please sign in to comment.