Skip to content

Commit

Permalink
Cleanup ScopedFile()
Browse files Browse the repository at this point in the history
Change-Id: I015dcededca634e322a5f1cad7eefa8d084d7997
  • Loading branch information
yjzhang111 committed Jul 13, 2024
1 parent e0f8599 commit a285aff
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions starboard/common/file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,9 @@ bool SbFileDeleteRecursive(const char* path, bool preserve_root) {

// The |path| points to a file. Remove it and return.
if (err != kSbFileOk) {
return SbFileDelete(path);
return (unlink(path) == 0);
}

SbFileInfo info;

std::vector<char> entry(kSbFileMaxName);

while (SbDirectoryGetNext(dir, entry.data(), kSbFileMaxName)) {
Expand All @@ -110,7 +108,7 @@ bool SbFileDeleteRecursive(const char* path, bool preserve_root) {

// Don't forget to close and remove the directory before returning!
if (DirectoryCloseLogFailure(path, dir)) {
return preserve_root ? true : SbFileDelete(path);
return preserve_root ? true : (rmdir(path) == 0);
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion starboard/loader_app/drain_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ bool TryDrain(const char* dir, const char* app_key) {
path.append(filename);

SbFileError error = kSbFileOk;
int file = open(path.c_str(), O_CREAT | O_WRONLY);
int file = open(path.c_str(), O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);

SB_DCHECK(file >= 0);
SB_DCHECK(close(file));
Expand Down

0 comments on commit a285aff

Please sign in to comment.